/* HRI Learn — Apply track
   Mobile-first, ~440px column. Every colour comes from a token, so the light
   theme is a token swap rather than a pile of per-selector overrides. */

/* ---------------------------------------------------------------- tokens */

:root,
html[data-theme="light"] {
  color-scheme: light;

  --bg: #fffdf7;
  --bg-tint-a: rgba(166, 124, 27, 0.09);
  --bg-tint-b: rgba(92, 122, 146, 0.07);
  --surface: #ffffff;
  --surface-soft: #f6f2e6;
  --surface-sunk: #f1ece0;

  --text: #17150f;
  --text-soft: #3f3a30;
  --text-faint: #5f5849;

  --border: rgba(23, 21, 15, 0.13);
  --border-strong: rgba(23, 21, 15, 0.24);

  --accent: #8a6416;
  --accent-ink: #6d4e0f;
  --accent-soft: rgba(138, 100, 22, 0.12);
  --accent-contrast: #fffdf7;

  --ok: #2f5c3f;
  --ok-soft: rgba(47, 92, 63, 0.12);

  --chrome: rgba(255, 253, 247, 0.94);
  --chrome-fade: rgba(255, 253, 247, 0);

  --code-bg: #f4efe2;
  --code-text: #221f17;
  --diagram-bg: #f4efe2;

  --shadow: 0 14px 34px rgba(15, 13, 9, 0.09);
  --shadow-soft: 0 4px 14px rgba(15, 13, 9, 0.06);

  --toast-bg: #17150f;
  --toast-text: #fffdf7;

  --radius: 16px;
  --radius-sm: 11px;

  --ui: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --display: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tap: 48px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0a0b;
  --bg-tint-a: rgba(201, 169, 98, 0.08);
  --bg-tint-b: rgba(139, 163, 184, 0.05);
  --surface: #151517;
  --surface-soft: #1c1c1f;
  --surface-sunk: #202024;

  --text: #f4f1ea;
  --text-soft: #cfcbc2;
  --text-faint: #97938a;

  --border: rgba(244, 241, 234, 0.1);
  --border-strong: rgba(244, 241, 234, 0.2);

  --accent: #c9a962;
  --accent-ink: #dcc084;
  --accent-soft: rgba(201, 169, 98, 0.16);
  --accent-contrast: #17150f;

  --ok: #7fb391;
  --ok-soft: rgba(127, 179, 145, 0.14);

  --chrome: rgba(10, 10, 11, 0.94);
  --chrome-fade: rgba(10, 10, 11, 0);

  --code-bg: #101012;
  --code-text: #e6e2d9;
  --diagram-bg: #0d0d0e;

  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.35);

  --toast-bg: #f4f1ea;
  --toast-text: #17150f;
}

/* ----------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(900px 480px at 50% -8%, var(--bg-tint-a), transparent 55%),
    radial-gradient(700px 400px at 100% 8%, var(--bg-tint-b), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.app {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(8px + var(--safe-top)) calc(16px + var(--safe-right))
    calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

.main {
  flex: 1;
  outline: none;
}

.screen[hidden] {
  display: none;
}

/* --------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 6px 0 10px;
  background: linear-gradient(to bottom, var(--chrome) 62%, var(--chrome-fade));
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.brand-mark {
  color: var(--accent-ink);
}

.brand-sep {
  color: var(--text-faint);
}

.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 10px 0 4px;
  margin-left: -4px;
  background: none;
  border: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
}

.topbar-back[hidden] {
  display: none;
}

.topbar-back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.applied-count {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  white-space: nowrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the icon for the theme you would switch *to*. */
html[data-theme="light"] .icon-sun,
html[data-theme="dark"] .icon-moon {
  display: none;
}

/* ------------------------------------------------------------ typography */

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 23px;
  line-height: 1.2;
}

h3 {
  font-size: 17px;
  line-height: 1.3;
}

p {
  margin: 0;
  color: var(--text-soft);
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.kicker .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.lede {
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-soft);
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

.hero {
  padding: 22px 18px 20px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 10px 0 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
}

.compare {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compare-item {
  border-left: 2px solid var(--border-strong);
  padding-left: 12px;
}

.compare-item.is-current {
  border-left-color: var(--accent);
}

.compare-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.compare-item.is-current .compare-label {
  color: var(--accent-ink);
}

.compare-item p {
  font-size: 14.5px;
  line-height: 1.5;
}

.note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-faint);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 2px 0 -4px;
}

/* ------------------------------------------------------------ unit list */

.unit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.unit-row {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  text-align: left;
  padding: 15px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.unit-row:active {
  transform: scale(0.99);
}

.unit-row.is-next {
  border-color: var(--accent);
}

.unit-row.is-locked {
  background: var(--surface-soft);
  box-shadow: none;
  opacity: 0.72;
}

.unit-badge {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-soft);
}

.unit-row.is-done .unit-badge {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}

.unit-row.is-next .unit-badge {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.unit-badge svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.unit-badge .lock-icon {
  stroke-width: 1.8;
}

.unit-copy {
  min-width: 0;
}

.unit-copy .t {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.unit-copy .k {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin-top: 2px;
}

.unit-status {
  margin-left: auto;
  flex: 0 0 auto;
  align-self: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.unit-status.is-done {
  color: var(--ok);
}

.unit-status.is-next {
  color: var(--accent-ink);
}

/* ---------------------------------------------------------- unit detail */

.teach p {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 13px;
}

.teach p:last-child {
  margin-bottom: 0;
}

/* Unit intro video. Sits at the top of the unit, above the teach copy: full
   width of the app column, vertical (9/16) but capped so it cannot eat a tall
   phone screen. Never autoplays — tap to play. */
.intro-video {
  margin: 0 0 16px;
}

.intro-video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: min(70vh, 520px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0b0b0c;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.intro-video-el {
  display: block;
  width: 100%;
  height: 100%;
  /* contain, not cover: the frame letterboxes against its own dark chrome
     rather than cropping the video on either theme's card background. */
  object-fit: contain;
  background: #0b0b0c;
  color-scheme: dark;
}

/* Decorative play affordance over the poster. Click-through, so the tap still
   reaches the video's own controls. */
.intro-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(11, 11, 12, 0.55);
  border: 1.5px solid rgba(255, 253, 247, 0.85);
  color: #fffdf7;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 1;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.intro-video-play svg {
  width: 26px;
  height: 26px;
  margin-left: 3px;
}

.intro-video.is-playing .intro-video-play {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
}

.intro-video-caption {
  margin: 9px 2px 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-faint);
}

@media (prefers-reduced-motion: reduce) {
  .intro-video-play {
    transition: none;
  }
}

.diagram {
  margin: 4px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--diagram-bg);
  overflow: hidden;
}

.diagram img {
  display: block;
  width: 100%;
  height: auto;
}

.schema {
  display: flex;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  font-size: 14.5px;
  line-height: 1.45;
  font-weight: 500;
  color: var(--text);
}

.schema::before {
  content: "";
  flex: 0 0 3px;
  border-radius: 2px;
  background: var(--accent);
}

/* ------------------------------------------------------------- handoff */

.handoff {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.handoff-head {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.handoff-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  margin-bottom: 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.handoff-head h3 {
  margin-bottom: 6px;
}

.handoff-instruction {
  font-size: 14.5px;
  line-height: 1.5;
}

.prompt-wrap {
  position: relative;
  background: var(--code-bg);
  border-bottom: 1px solid var(--border);
}

.prompt-pre {
  margin: 0;
  padding: 14px 15px;
  max-height: 260px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--code-text);
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.prompt-wrap.is-collapsed .prompt-pre {
  max-height: 168px;
  overflow: hidden;
}

.prompt-wrap.is-collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 62px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--code-bg));
}

.prompt-expand {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  padding: 9px;
  border: 0;
  border-top: 1px solid var(--border);
  background: var(--code-bg);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-ink);
}

.handoff-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 16px 16px;
}

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 13px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border);
}

.btn-quiet {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
}

.btn-done {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok);
}

/* -------------------------------------------------------- domain picker */

.picker {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.picker h3 {
  margin-bottom: 4px;
}

.picker .note {
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.tip {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.tip .tip-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 5px;
}

.tip p {
  font-size: 14.5px;
  line-height: 1.5;
}

.applied-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  border: 1px solid var(--ok);
  color: var(--ok);
  font-size: 14px;
  font-weight: 600;
}

.applied-banner svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -------------------------------------------------------------- summary */

.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.summary-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14.5px;
  color: var(--text-soft);
}

.summary-list .n {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

.summary-list .d {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
  white-space: nowrap;
}

/* ----------------------------------------------------------------- dock */

.dock {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--chrome) 68%, var(--chrome-fade));
}

.dock[hidden] {
  display: none;
}

.dock-row {
  display: flex;
  justify-content: center;
}

.footer-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 8px 0 4px;
  margin: 0;
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translate(-50%, 10px);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast[hidden] {
  display: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* -------------------------------------------------------------- motion */

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

/* Wider screens keep the phone column but get a little more air. */
@media (min-width: 480px) {
  .app {
    padding-top: 18px;
  }
}
