/* Design tokens, fonts and shared parts. Layout of the shell is in shell.css. */

@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('../../vendor/fonts/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('../../vendor/fonts/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Bangers';
  src: url('../../vendor/fonts/bangers-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  /* Dark theme (Rishabh, 2026-11-29). A light set waits below for the
     theme setting in the settings store. */
  color-scheme: dark;
  --ink: #f2f0ea;
  --ink-muted: #c4c2ba;
  --paper: #121216;
  --panel: #1f1f26;
  --edge: #e8e5dc;
  --shadow-color: #000000;
  --accent: #ff6b6b;
  --accent-ink: #121216;
  --highlight: #ffd23f;
  --highlight-ink: #121216;
  --tone-stories: #f4845f;
  --tone-cards: #3cc5b4;
  --tone-quiz: #6fa8dc;
  --tone-soon: #9aa5b8;
  --line: 3px;
  --shadow: 4px 4px 0 var(--shadow-color);
  --radius: 10px;
  --tap: 44px;
  --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bangers', 'Comic Sans MS', 'Chalkboard SE', cursive;
}

:root[data-theme='light'] {
  color-scheme: light;
  --ink: #1b1b1f;
  --ink-muted: #4a4a55;
  --paper: #fffdf7;
  --panel: #ffffff;
  --edge: #1b1b1f;
  --shadow-color: #1b1b1f;
  --accent: #c1121f;
  --accent-ink: #ffffff;
  --highlight: #ffe066;
  --highlight-ink: #1b1b1f;
  --tone-stories: #e76f51;
  --tone-cards: #2a9d8f;
  --tone-quiz: #457b9d;
  --tone-soon: #8d99ae;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

h1,
h2,
.brand {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  margin: 0 0 8px;
}

h2 {
  font-size: 1.6rem;
  margin: 0 0 8px;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

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

[data-screen-title]:focus {
  outline: none;
}

.muted {
  color: var(--ink-muted);
}

/* Buttons: always at least 44 px tall and wide, so they are easy to tap. */
/* The hidden attribute always wins, even over components that set display. */
[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 8px 18px;
  border: var(--line) solid var(--edge);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow-color);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.btn-small {
  padding: 4px 12px;
  box-shadow: none;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Cards look like comic panels: thick ink outline, offset shadow. */
.card {
  background: var(--panel);
  border: var(--line) solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-top-width: 10px;
  border-top-color: var(--tone, var(--edge));
}

.card[data-tone='stories'] { --tone: var(--tone-stories); }
.card[data-tone='cards'] { --tone: var(--tone-cards); }
.card[data-tone='quiz'] { --tone: var(--tone-quiz); }
.card[data-tone='soon'] { --tone: var(--tone-soon); }

.card p {
  margin: 0 0 16px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.card-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 24px;
}

.plan-list {
  margin: 0 0 12px;
  padding-left: 1.2em;
}

.dialog {
  border: var(--line) solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--panel);
  color: var(--ink);
  padding: 24px;
  max-width: min(480px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

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

/* Profile pictures: an avatar glyph, a photo or an initial in a round comic
   badge. Always shown with a name. */
.avatar {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: var(--line) solid var(--edge);
  border-radius: 50%;
  background: var(--paper);
  line-height: 1;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-initial {
  font-family: var(--font-display);
  background: var(--tone-stories);
  color: var(--accent-ink);
}

.avatar-large {
  width: 72px;
  height: 72px;
  font-size: 2.4rem;
  margin-bottom: 12px;
}

.avatar-small {
  width: 30px;
  height: 30px;
  font-size: 1.05rem;
  border-width: 2px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--highlight);
  color: var(--highlight-ink);
  font-weight: 700;
  font-size: 0.9rem;
}

/* Forms */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.field label,
.choice-group legend {
  font-weight: 700;
}

.field input {
  min-height: var(--tap);
  padding: 8px 12px;
  border: var(--line) solid var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.choice-group {
  border: 0;
  margin: 0 0 18px;
  padding: 0;
}

.choice-group legend {
  margin-bottom: 8px;
  padding: 0;
}

.choice-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
}

.choice {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 8px 6px;
  border: 2px solid var(--ink-muted);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  text-align: center;
  font-weight: 700;
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.choice:has(input:checked) {
  border: var(--line) solid var(--highlight);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.choice:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.choice-glyph {
  font-size: 1.8rem;
  line-height: 1.2;
}

.form-error {
  min-height: 1.5em;
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 700;
}

.form-error:empty {
  min-height: 0;
}

.dialog form {
  margin: 0;
}

.profile-grid {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.profile-card[data-current='true'] {
  --tone: var(--highlight);
}

.profile-card .badge {
  margin: 0 0 12px;
}

.profile-button {
  gap: 8px;
}

.profile-name {
  max-width: 10ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog:modal {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.transfer-card {
  margin-top: 8px;
}

.transfer-status {
  margin: 16px 0 0;
  font-weight: 700;
}

.transfer-status:empty {
  margin: 0;
}

/* Profile form: the photo choice shows the chosen photo, and the "Choose a
   photo" button opens the file chooser (the file input itself is hidden). */
.photo-preview {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-button {
  margin-top: 12px;
  cursor: pointer;
}

.photo-button:has(+ #profile-photo:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.field-hint {
  margin: 8px 0 0;
  font-size: 0.875rem;
}
