/*
 * Shared chrome for every app page (docs/product/Visual_Design.md § 3–4):
 * the base page, buttons, the top bar, the grown-up gate, reader discs.
 * Page sheets add layout only. Values come from tokens.css.
 */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--surface-page);
  color: var(--text-ink);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--pip-ink);
  outline-offset: 3px;
}

/* Buttons: 56 px, radius 12, Andika Bold 22. Primary is ink; secondary is a
   2 px ink outline. .big-btn is the primary everywhere. */
.big-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: var(--button-height);
  padding: 0 1.4em;
  border: 2px solid var(--action-primary-bg);
  border-radius: var(--radius-button);
  background: var(--action-primary-bg);
  color: var(--action-primary-fg);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text-ink);
}

.big-btn:active,
.btn:active {
  transform: translateY(1px);
}

.btn-secondary:active {
  background: var(--surface-pressed);
}

.big-btn:disabled,
.btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* Quiet actions: bold ink text, no box — Close, Grown-ups, Skip to book. */
.quiet-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: 0;
  border: none;
  background: none;
  color: var(--text-ink);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

/* The frame's top bar: Close · title · one quiet action. */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 var(--gutter);
}

.topbar > :first-child {
  justify-self: start;
}

.topbar > a,
.topbar > button {
  white-space: nowrap;
}

.topbar > :last-child {
  justify-self: end;
}

.topbar-title {
  margin: 0;
  font-size: 18px;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* A reader's initial on their own color — the one place a color appears in
   chrome (Visual_Design.md § 3 rule 10). */
.reader-dot {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  color: var(--neutral-0);
  font-weight: 700;
  line-height: 1;
}

/* The grown-up gate — a typed number in words, shared everywhere. */
.gate {
  margin: 16px auto 0;
  padding: 20px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-card);
  max-width: 24rem;
  text-align: left;
}

.gate-prompt {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--text-muted);
}

.gate-input {
  min-height: var(--touch-min);
  width: 7rem;
  padding: 0 14px;
  border: 2px solid var(--pip-ink);
  border-radius: var(--radius-button);
  background: var(--surface-page);
  font-size: 22px;
  text-align: center;
}

.gate-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  margin-left: 10px;
  padding: 0 18px;
  border: 2px solid var(--action-primary-bg);
  border-radius: var(--radius-button);
  background: var(--action-primary-bg);
  color: var(--action-primary-fg);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.gate-no .gate-input {
  border-width: 3px;
  border-style: dashed;
}

/* A small set of choices behind the gate: the current one is ink. */
.choices {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  min-height: var(--touch-min);
  padding: 0 16px;
  border: 2px solid var(--pip-ink);
  border-radius: var(--radius-button);
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.choice.current {
  background: var(--action-primary-bg);
  color: var(--action-primary-fg);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
