/* Base: the shell, the one headline, the one button, the top bar. Views add their own sheets. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0; min-height: 100dvh; background: var(--ground); color: var(--ink);
  font: var(--w-regular) var(--t-body)/1.45 var(--font-text);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.display { font-family: var(--font-display); font-weight: var(--w-bold); font-size: var(--t-display); line-height: 1.02; letter-spacing: -0.02em; font-variation-settings: 'opsz' 144, 'SOFT' 30; }
.title { font-family: var(--font-display); font-weight: var(--w-bold); font-size: var(--t-title); line-height: 1.1; letter-spacing: -0.01em; }
.meta { font-size: var(--t-meta); color: var(--ink-55); }
.hero { font-family: var(--font-mono); font-size: var(--t-hero); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* screens */
#app { position: relative; min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; padding: 0 var(--gutter) var(--s-6); max-width: var(--max); margin: 0 auto; }
.screen[data-active] { display: flex; flex-direction: column; }

/* top bar: 44px rows, back, counter, theme */
.bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); height: 56px; margin: 0 calc(-1 * var(--s-2)); }
.bar .counter { font-family: var(--font-mono); font-size: var(--t-meta); color: var(--ink-55); letter-spacing: 0.04em; white-space: nowrap; }
.keranaut-brand {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--hit); padding: 4px 6px; border-radius: var(--r-thumb);
  text-decoration: none;
}
.keranaut-brand img {
  display: block; height: 22px; width: auto; max-width: 150px; object-fit: contain;
  filter: contrast(1.18) brightness(1.04);
  mix-blend-mode: multiply;
}
.keranaut-brand.keranaut-mark img {
  height: 24px;
  max-width: 44px;
}
:root[data-theme='night'] .keranaut-brand img,
:root[data-theme='orrery'] .keranaut-brand img,
:root[data-theme='blue'] .keranaut-brand img,
:root[data-theme='steampunk'] .keranaut-brand img {
  filter: grayscale(1) contrast(1.35) invert(1);
  mix-blend-mode: screen;
}
.icon-btn {
  width: var(--hit); height: var(--hit); display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: var(--r-chip); color: var(--ink);
}
.icon-btn:hover { background: var(--ink-08); }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[hidden] { visibility: hidden; display: inline-grid; }

/* the one button */
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; padding: 0 var(--s-5);
  border: 0; border-radius: var(--r-card); background: var(--fill); color: var(--fill-ink);
  font-weight: var(--w-bold); font-size: var(--t-row); letter-spacing: 0.01em; transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.btn:active { transform: scale(0.985); }
.btn[disabled] { opacity: 0.3; cursor: default; }
.btn.quiet { background: transparent; color: var(--ink-55); font-weight: var(--w-regular); min-height: var(--hit); }
.btn.quiet:hover { color: var(--ink); }
.link { background: none; border: 0; padding: var(--s-3) 0; color: var(--ink-55); text-decoration: underline; text-underline-offset: 3px; min-height: var(--hit); }
.link:hover { color: var(--ink); }
.actions { margin-top: auto; padding-top: var(--s-5); display: grid; gap: var(--s-2); }

/* cover: on the phone the shape sits above the words; on the desktop the words sit left, mid-height, the shape large on the right */
#screen-cover[data-active] { display: flex; flex-direction: column; position: relative; }
#screen-cover .cover-left { display: flex; flex-direction: column; flex: 1; }
#screen-cover .cover-left .bar { position: absolute; top: 0; left: var(--gutter); right: var(--gutter); }
#screen-cover .cover-right { order: -1; margin-top: 56px; }
.cover-title { margin-top: var(--s-4); }
.cover-meta { margin-top: var(--s-3); font-size: var(--t-body); color: var(--ink-55); line-height: 1.45; max-width: 340px; }
@media (min-width: 900px) {
  #screen-cover[data-active] { display: grid; }
  #screen-cover .cover-right { order: 0; }
  #screen-cover .cover-left { justify-content: center; }
  #screen-cover .cover-right { margin-top: 0; }
  #screen-cover .cover-words { margin-top: 0; }
  #screen-cover .cover-left .actions { margin-top: var(--s-6); max-width: 360px; }
  #screen-cover .ink-cover { height: min(80vh, 760px); margin: 0; }
}

/* dot grid, used behind the shape */
.dots { background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 16px 16px; }

/* delta chips */
.delta { font-family: var(--font-mono); font-size: var(--t-meta); color: var(--ink-55); opacity: 0; transition: opacity var(--dur-fast); }
.delta[data-show] { opacity: 1; }
.delta.up { color: var(--accent); }

/* toast slot: reserved so nothing shifts */
#toast { position: fixed; left: 50%; bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: var(--s-2) var(--s-4); border-radius: var(--r-chip); background: var(--fill); color: var(--fill-ink); font-size: var(--t-meta); opacity: 0; pointer-events: none; transition: opacity var(--dur-fast); }
#toast[data-show] { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
@media (min-width: 900px) {
  .screen { max-width: none; padding-left: var(--gutter); padding-right: var(--gutter); }
  .screen[data-active] { display: grid; grid-template-columns: minmax(360px, 520px) 1fr; column-gap: var(--s-6); align-items: start; }
  .screen > .left { display: flex; flex-direction: column; min-height: 100dvh; }
  .screen > .right { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
}
