/* Emotions Mentor — The Impact
   Calm course player in the EM brand palette.
   Grounds: night blue for the cinematic surfaces (login, hub, video),
   cream paper for reading and writing. Gold acts, olive affirms. */

/* ---------- Fonts (self-hosted) ---------- */

@font-face {
  font-family: 'Literata';
  src: url('../assets/fonts/literata-var.woff2') format('woff2');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Literata';
  src: url('../assets/fonts/literata-italic-var.woff2') format('woff2');
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito Sans';
  src: url('../assets/fonts/nunito-sans-var.woff2') format('woff2');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito Sans';
  src: url('../assets/fonts/nunito-sans-italic-var.woff2') format('woff2');
  font-weight: 200 1000;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  /* night (brand dark blue ramp) */
  --night-950: #01050c;
  --night-900: #02101d;
  --night-850: #051c30;   /* brand Hero Dark Blue */
  --night-800: #0b2a44;
  --night-700: #385067;
  /* slate (brand hero light blue ramp) */
  --slate-100: #d8e1e3;
  --slate-200: #c5d2d5;
  --slate-300: #b2c3c7;
  --slate-400: #9fb5ba;
  --slate-500: #758689;
  /* paper (brand cream / beige ramp) */
  --paper: #f7f2e7;
  --paper-shade: #eee1d6;
  --paper-deep: #e5d2c2;
  /* ink on paper */
  --ink: #2e2e2e;
  --ink-soft: #69594b;    /* warm secondary, from the beige ramp */
  /* gold (brand gold ramp) */
  --gold-300: #e9ddc3;
  --gold-400: #d3bb88;
  --gold-500: #c8aa69;
  --gold-700: #635331;
  /* olive (brand olive ramp) */
  --olive-300: #b1b8a3;
  --olive-400: #818b69;
  --olive-600: #5e664c;
  --olive-800: #3e4331;
  /* blue (brand blue ramp, module grading) */
  --blue-400: #4f6b77;

  --font-display: 'Literata', Georgia, serif;
  --font-ui: 'Nunito Sans', -apple-system, 'Segoe UI', sans-serif;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  --radius-s: 0.5rem;
  --radius-m: 0.875rem;
  --radius-l: 1.25rem;

  --shadow-soft: 0 1px 2px rgba(1, 5, 12, 0.25), 0 8px 28px rgba(1, 5, 12, 0.35);
  --shadow-paper: 0 1px 2px rgba(46, 46, 46, 0.08), 0 10px 30px rgba(46, 46, 46, 0.12);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--paper);
  background: var(--night-850);
  min-height: 100dvh;
}

body.on-paper {
  background: var(--paper);
  color: var(--ink);
}

img, video { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 430;
  line-height: 1.15;
  margin: 0 0 var(--space-4);
  text-wrap: balance;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.9rem, 4.5vw + 1rem, 3.1rem); }
h2 { font-size: clamp(1.4rem, 2vw + 0.9rem, 1.9rem); }
h3 { font-size: 1.17rem; font-family: var(--font-ui); font-weight: 700; }

p { margin: 0 0 var(--space-4); max-width: 66ch; }

a { color: var(--gold-400); text-underline-offset: 3px; }
.on-paper a { color: var(--gold-700); }

:focus-visible {
  outline: 3px solid var(--gold-400);
  outline-offset: 2px;
  border-radius: 2px;
}
.on-paper :focus-visible { outline-color: var(--gold-700); }

::selection { background: var(--gold-400); color: var(--night-900); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Layout primitives ---------- */

.shell {
  width: min(100% - 2.5rem, 68rem);
  margin-inline: auto;
}
.shell--narrow { width: min(100% - 2.5rem, 44rem); }
.shell--read { width: min(100% - 2.5rem, 40rem); }

.stack-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.stack-page > main { flex: 1; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}
.topbar__logo { height: 2.75rem; width: auto; }
.topbar__logo--wide { height: 2.1rem; }
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: 0.9rem;
}
.topbar__uid {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--slate-300);
}
.on-paper .topbar__uid { color: var(--ink-soft); }
.topbar__link {
  color: var(--slate-200);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.topbar__link:hover { border-bottom-color: currentColor; }
.on-paper .topbar__link { color: var(--ink-soft); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  padding: 0.8em 1.7em;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 180ms var(--ease-out), transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.btn:active { transform: scale(0.98); }

.btn--gold {
  background: var(--gold-400);
  color: var(--night-900);
  box-shadow: 0 2px 10px rgba(1, 5, 12, 0.3);
}
.btn--gold:hover { background: var(--gold-300); }
.on-paper .btn--gold { box-shadow: 0 2px 10px rgba(99, 83, 49, 0.25); }

.btn--ghost {
  background: transparent;
  color: var(--slate-100);
  border: 1.5px solid var(--night-700);
}
.btn--ghost:hover { border-color: var(--slate-400); }
.on-paper .btn--ghost {
  color: var(--ink);
  border-color: var(--paper-deep);
}
.on-paper .btn--ghost:hover { border-color: var(--ink-soft); }

.btn--quiet {
  background: none;
  border: none;
  color: var(--slate-200);
  font-weight: 650;
  padding: 0.5em 0.75em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.on-paper .btn--quiet { color: var(--ink-soft); }

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn .icon { width: 1.05em; height: 1.05em; }

/* ---------- Icons ---------- */

.icon {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon--fill { fill: currentColor; stroke: none; }

/* ---------- Login ---------- */

.login {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  isolation: isolate;
  overflow: clip;
}
.login__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
}
.login__backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 70% 30%;
  opacity: 0.6;
  filter: saturate(0.6);
  animation: drift 42s var(--ease-out) both;
}
@keyframes drift {
  from { transform: scale(1.09) translateY(-1%); }
  to   { transform: scale(1); translateY(0); }
}
.login__backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 28, 48, 0.35) 0%, rgba(5, 28, 48, 0.68) 55%, #051c30 90%),
    linear-gradient(100deg, rgba(2, 16, 29, 0.6) 0%, rgba(2, 16, 29, 0.08) 60%);
}

.login__body {
  display: grid;
  align-content: end;
  padding-top: var(--space-8);
}
.login__logo { height: 5.5rem; width: auto; margin-bottom: var(--space-6); }
.login__title {
  font-size: clamp(2.6rem, 8vw + 0.5rem, 4.6rem);
  font-weight: 380;
  margin-bottom: var(--space-2);
}
.login__sub {
  color: var(--slate-200);
  font-size: 1.05rem;
  margin-bottom: var(--space-6);
}

.login__panel { padding-bottom: var(--space-7); }

.code-form { max-width: 26rem; }
.code-label {
  display: block;
  font-weight: 750;
  font-size: 0.95rem;
  margin-bottom: var(--space-2);
}
.code-row { display: flex; gap: var(--space-3); }
.code-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  text-align: center;
  color: var(--paper);
  background: rgba(2, 16, 29, 0.55);
  border: 1.5px solid var(--night-700);
  border-radius: var(--radius-m);
  padding: 0.6em 0.5em;
  transition: border-color 160ms var(--ease-out);
}
.code-input::placeholder {
  color: var(--slate-400);
  letter-spacing: 0.35em;
}
.code-input:focus { border-color: var(--gold-400); outline: none; }
.code-input[aria-invalid="true"] { border-color: #c96f5a; }

.field-error {
  color: #e5a696;
  font-size: 0.92rem;
  margin-top: var(--space-2);
  min-height: 1.4em;
}

.login__alt { margin-top: var(--space-5); }

.login__privacy {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  color: var(--slate-300);
  font-size: 0.9rem;
  max-width: 34rem;
  margin-top: var(--space-6);
}
.login__privacy .icon { margin-top: 0.15em; color: var(--olive-300); }

/* ---------- Calculator (four questions) ---------- */

.calc {
  border-top: 1px solid var(--night-700);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  max-width: 34rem;
}
.calc[hidden] { display: none; }
.calc h2 { font-size: 1.35rem; }
.calc__lead { color: var(--slate-200); font-size: 0.98rem; }
.calc__q { margin: var(--space-5) 0; }
.calc__q label {
  display: block;
  font-weight: 750;
  margin-bottom: var(--space-2);
}
.calc__q .hint {
  display: block;
  font-weight: 400;
  color: var(--slate-300);
  font-size: 0.92rem;
  margin-top: 0.2em;
  max-width: 46ch;
}
.calc__q input {
  font-family: var(--font-ui);
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  width: 7.5rem;
  color: var(--paper);
  background: rgba(2, 16, 29, 0.55);
  border: 1.5px solid var(--night-700);
  border-radius: var(--radius-s);
  padding: 0.45em 0.4em;
}
.calc__q input:focus { border-color: var(--gold-400); outline: none; }
.calc__result {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-5);
}
.calc__code {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--gold-300);
}

/* ---------- Intro (paper) ---------- */

.intro-hero { padding: var(--space-8) 0 var(--space-6); }
.intro-hero h1 { margin-bottom: var(--space-3); }
.intro-hero .lede {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink-soft);
}

.intro-list {
  list-style: none;
  margin: var(--space-6) 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}
.intro-list li {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  max-width: 60ch;
}
.intro-list .icon {
  color: var(--olive-400);
  margin-top: 0.25em;
}

.intro-note {
  background: var(--paper-shade);
  border-radius: var(--radius-m);
  padding: var(--space-5);
  max-width: 60ch;
  margin: var(--space-6) 0;
}
.intro-note p { margin: 0; font-size: 0.98rem; }
.intro-note p + p { margin-top: var(--space-3); }

.intro-cta { margin: var(--space-7) 0 var(--space-8); }

/* ---------- Module hub ---------- */

.hub-head { padding: var(--space-7) 0 var(--space-5); }
.hub-head h1 { margin-bottom: var(--space-2); }
.hub-head p { color: var(--slate-200); }

.module-grid {
  display: grid;
  gap: var(--space-5);
  padding-bottom: var(--space-7);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .module-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .module-grid { grid-template-columns: 1fr 1fr 1fr; } }

.module-card {
  position: relative;
  display: block;
  border-radius: var(--radius-l);
  overflow: hidden;
  text-decoration: none;
  color: var(--paper);
  background: var(--night-900);
  box-shadow: var(--shadow-soft);
  transition: transform 260ms var(--ease-out), box-shadow 260ms var(--ease-out);
  opacity: 0;
  translate: 0 14px;
  animation: card-in 640ms var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes card-in {
  to { opacity: 1; translate: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .module-card { opacity: 1; translate: none; animation: none; }
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 2px 4px rgba(1, 5, 12, 0.3), 0 18px 44px rgba(1, 5, 12, 0.5);
}

.module-card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}
.module-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.02);
  transition: transform 700ms var(--ease-out);
}
.module-card:hover .module-card__media img { transform: scale(1.045); }
.module-card__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tint) 55%, transparent) 0%, color-mix(in srgb, var(--tint) 20%, transparent) 45%, rgba(2, 16, 29, 0.88) 100%),
    linear-gradient(0deg, color-mix(in srgb, var(--tint) 32%, transparent), color-mix(in srgb, var(--tint) 32%, transparent));
  mix-blend-mode: multiply;
}
.module-card__media::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, transparent 40%, rgba(2, 16, 29, 0.72) 100%);
}

.module-card__body {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  padding: var(--space-4) var(--space-5) var(--space-5);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
}
.module-card__title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 460;
  line-height: 1.2;
  margin: 0;
}
.module-card__meta {
  color: var(--slate-200);
  font-size: 0.88rem;
  font-weight: 650;
  margin-top: var(--space-1);
}
.module-card__done {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--olive-300);
  background: rgba(2, 16, 29, 0.72);
  border-radius: 999px;
  padding: 0.3em 0.85em;
  font-size: 0.85rem;
  font-weight: 750;
}
.module-card__done .icon { width: 1rem; height: 1rem; }

.hub-aside {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  padding-bottom: var(--space-8);
  color: var(--slate-300);
  font-size: 0.95rem;
}

/* ---------- Session step shell ---------- */

.step-head { padding: var(--space-6) 0 var(--space-4); }
.step-head__module {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--slate-300);
  margin-bottom: var(--space-2);
}
.on-paper .step-head__module { color: var(--ink-soft); }
.step-head h1 { margin-bottom: var(--space-2); }

.step-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.step-progress__dot {
  width: 2.1rem;
  height: 0.3rem;
  border-radius: 999px;
  background: var(--night-700);
}
.on-paper .step-progress__dot { background: var(--paper-deep); }
.step-progress__dot.is-done { background: var(--olive-400); }
.step-progress__dot.is-now { background: var(--gold-400); }
.step-progress__label {
  margin-left: var(--space-2);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate-300);
}
.on-paper .step-progress__label { color: var(--ink-soft); }

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) 0 var(--space-8);
}

/* ---------- Video stage ---------- */

.stage {
  position: relative;
  border-radius: var(--radius-l);
  overflow: hidden;
  background: var(--night-950);
  box-shadow: var(--shadow-soft);
  margin-bottom: var(--space-5);
}
.stage__play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4.6rem;
  height: 4.6rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--gold-400);
  color: var(--night-900);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(1, 5, 12, 0.5);
  transition: transform 200ms var(--ease-out), background-color 200ms var(--ease-out);
}
.stage__play:hover { background: var(--gold-300); transform: scale(1.06); }
.stage__play .icon { width: 1.9rem; height: 1.9rem; }
.stage video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--night-950);
}
.stage-note {
  color: var(--slate-300);
  font-size: 0.95rem;
  max-width: 60ch;
}

/* ---------- Paper work surfaces ---------- */

.worksheet {
  background: #fffdf8;
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-paper);
  padding: clamp(1.25rem, 4vw, 2.5rem);
  margin-bottom: var(--space-5);
}
.worksheet h2 { margin-top: 0; }

.pending {
  border: 1.5px dashed var(--paper-deep);
  border-radius: var(--radius-m);
  padding: var(--space-5);
  color: var(--ink-soft);
}
.pending strong {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--gold-700);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.pending p { margin: 0; font-size: 0.98rem; }

.notes-field { margin-top: var(--space-5); }
.notes-field label {
  display: block;
  font-weight: 750;
  margin-bottom: var(--space-2);
}
.notes-field textarea {
  width: 100%;
  min-height: 9rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--paper-deep);
  border-radius: var(--radius-s);
  padding: 0.85em 1em;
  resize: vertical;
  transition: border-color 160ms var(--ease-out);
}
.notes-field textarea:focus { border-color: var(--gold-500); outline: none; }
.notes-field .device-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin-top: var(--space-2);
}
.notes-field .device-note .icon { width: 1rem; height: 1rem; color: var(--olive-600); }

/* ---------- Meditation ---------- */

.meditate-frame {
  text-align: center;
  padding-top: var(--space-6);
}
.meditate-frame .lede {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--slate-200);
  max-width: 44ch;
  margin-inline: auto;
}

/* ---------- Summary ---------- */

.summary-sheet {
  background: #fffdf8;
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-paper);
  padding: clamp(1.5rem, 5vw, 3rem);
  margin-bottom: var(--space-6);
}
.summary-sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 2px solid var(--paper-shade);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
}
.summary-sheet header img { height: 2.4rem; }
.summary-sheet header .uid {
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
}
.summary-module { margin-bottom: var(--space-6); }
.summary-module h2 {
  font-size: 1.3rem;
  border-bottom: 1px solid var(--paper-shade);
  padding-bottom: var(--space-2);
}
.summary-entry { margin-bottom: var(--space-4); }
.summary-entry h3 { margin-bottom: var(--space-1); font-size: 0.95rem; color: var(--ink-soft); }
.summary-entry p {
  font-family: var(--font-display);
  white-space: pre-wrap;
  margin: 0;
}
.summary-empty { color: var(--ink-soft); }

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  padding-bottom: var(--space-8);
}

/* ---------- Footer ---------- */

.sitefoot {
  padding: var(--space-6) 0;
  color: var(--slate-500);
  font-size: 0.85rem;
}
.on-paper .sitefoot { color: var(--ink-soft); }
.sitefoot p { margin: 0; max-width: none; }

/* ---------- Print (session summary → PDF) ---------- */

@media print {
  @page { margin: 18mm 16mm; }
  body, body.on-paper { background: #fff; color: #000; }
  .topbar, .summary-actions, .sitefoot, .no-print { display: none !important; }
  .summary-sheet { box-shadow: none; border-radius: 0; padding: 0; }
  .shell, .shell--narrow, .shell--read { width: 100%; }
  .step-head { padding-top: 0; }
  a { color: inherit; text-decoration: none; }
}
