/*
 * TraumaCompendium on the web.
 *
 * The tokens are the app's, from src/theme/tokens.ts, not the marketing
 * site's. They are different systems on purpose and I had them confused:
 * traumacompendium.org is flat, square and editorial; the app is soft,
 * lifted and rounded, because one is a publisher's page and the other is
 * a place somebody sits with their own difficulty.
 *
 * The rules that carry it:
 *   a card is lifted by light, not outlined by a border
 *   nothing has a sharp apex
 *   amber is the one saturated surface, and it casts its own colour
 *   motion is slow on purpose; abrupt leaps induce anxiety
 */

:root {
  /* Ground plane: four stops, painted as one gradient. */
  --canvas: #fff8e1;
  --canvas-mid: #fffdf4;
  --canvas-cool: #fafbfe;
  --canvas-deep: #f2f5fd;

  --surface: #ffffff;
  --surface-subtle: #fafbfe;
  --surface-sunken: #f4f5f8;

  --primary: #15171a;
  --primary-soft: #3c4147;
  --primary-tint: #fdf3dc;
  --primary-tint-deep: #f8ce70;
  --on-primary: #ffffff;

  --amber1: #f8ce70;
  --amber2: #f2b13c;
  --accent: #fd9937;
  --accent-deep: #f2641e;
  --on-amber: #3a2a08;

  /* Reflective surfaces: journal, check-ins. */
  --secondary: #6b5bd2;
  --secondary-soft: #8a7edc;
  --secondary-tint: #ece9fb;

  /* Somatic warmth: mood. */
  --tertiary: #e8846b;
  --tertiary-soft: #f0a692;
  --tertiary-tint: #fbe7e1;

  --text: #15171a;
  --text-muted: #6b7076;
  --text-faint: #9aa0a6;

  --border: rgba(21, 23, 26, 0.08);
  --border-strong: rgba(21, 23, 26, 0.14);

  --danger: #a8432b;
  --danger-tint: #fbe7e1;
  --success: #2f7d53;
  --success-tint: #e3f3e9;
  --warning: #9a6b16;
  --warning-tint: #fbf0d8;

  --focus-ring: rgba(248, 206, 112, 0.3);
  --overlay: rgba(21, 23, 26, 0.45);

  /* No sharp apexes. */
  --r-sm: 8px;
  --r-md: 13px;
  --r-lg: 15px;
  --r-xl: 20px;
  --r-2xl: 26px;
  --r-pill: 999px;

  /* Lifted by light. Wide, soft, low opacity ink. */
  --lift-resting: 0 7px 18px rgba(21, 23, 26, 0.1);
  --lift-lifted: 0 14px 30px rgba(21, 23, 26, 0.16);
  --lift-amber: 0 10px 22px rgba(242, 177, 60, 0.5);
  --lift-nav: 0 -4px 16px rgba(21, 23, 26, 0.07);

  --gutter: 22px;
  --shell: 760px;

  /* Slow and linear. Abrupt leaps induce anxiety. */
  --calm: 400ms;
  --quick: 220ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  color-scheme: light dark;
}

/* Ember: the app's warm dark, not an inversion of the light palette. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --canvas: #1f160f;
    --canvas-mid: #241a12;
    --canvas-cool: #1c130c;
    --canvas-deep: #190f09;

    --surface: #2c2017;
    --surface-subtle: #271c14;
    --surface-sunken: #221810;

    --primary: #f3ede7;
    --primary-soft: #d5c2b9;
    --primary-tint: #3a2a1a;
    --primary-tint-deep: #503925;
    --on-primary: #1f160f;

    --amber1: #f0c479;
    --amber2: #e0a555;
    --accent: #e08a4b;
    --accent-deep: #f0a268;
    --on-amber: #241709;

    --secondary: #a99be8;
    --secondary-soft: #bcb1ef;
    --secondary-tint: #2e2742;

    --tertiary: #f0a692;
    --tertiary-soft: #f5c2b4;
    --tertiary-tint: #3d281f;

    --text: #f3ede7;
    --text-muted: #c0ab9c;
    --text-faint: #95806f;

    --border: rgba(255, 245, 235, 0.1);
    --border-strong: rgba(255, 245, 235, 0.18);

    --danger: #f2b8b5;
    --danger-tint: #3b211c;
    --success: #9fbf78;
    --success-tint: #22301c;
    --warning: #e0b96b;
    --warning-tint: #332714;

    --focus-ring: rgba(240, 196, 121, 0.32);

    --lift-resting: 0 7px 18px rgba(0, 0, 0, 0.4);
    --lift-lifted: 0 14px 30px rgba(0, 0, 0, 0.5);
    --lift-amber: 0 10px 22px rgba(224, 165, 85, 0.28);
    --lift-nav: 0 -4px 16px rgba(0, 0, 0, 0.35);
  }
}

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

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

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

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text-muted);
  font: 400 15px/25px 'Atkinson Hyperlegible', Georgia, serif;
  letter-spacing: 0.1px;
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-font-smoothing: antialiased;

  background: linear-gradient(
    180deg,
    var(--canvas) 0%,
    var(--canvas-mid) 34%,
    var(--canvas-cool) 68%,
    var(--canvas-deep) 100%
  ) fixed;
}

h1, h2, h3, h4, .brand, .btn, .stat__n, .level__n, .score {
  font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
}

h1 { font: 700 28px/35px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.4px; color: var(--text); margin: 0; }
h2 { font: 600 22px/29px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.2px; color: var(--text); margin: 32px 0 12px; }
h3 { font: 600 18px/25px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.1px; color: var(--text); margin: 0; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: var(--accent-deep); }

.kicker, .entry__date, .stat__label, .level__state, .field label, .detail dt, .checkins__when {
  display: block;
  font: 600 11.5px/16px 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.lede { font-size: 17px; line-height: 28px; color: var(--text-muted); margin: 10px 0 0; }
.quiet { font-size: 13.5px; line-height: 21px; color: var(--text-faint); }
.centred { text-align: center; }
.pad { padding-block: 64px; }

.shell { width: 100%; max-width: var(--shell); margin: 0 auto; padding-inline: var(--gutter); }
.page { padding-bottom: 110px; }
.rule { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

/* ---------------------------------------------------------------- */
/* The bar across the top                                            */
/* ---------------------------------------------------------------- */

/*
 * Three pixels, above everything, outside the safe area so it is not
 * hidden under a notch. It is the only thing on the page that moves
 * quickly: the rest of the app is deliberately unhurried, and a
 * progress indicator that dawdles defeats its own purpose.
 */
.progress {
  position: fixed;
  top: env(safe-area-inset-top, 0px); left: 0; right: 0;
  height: 3px; z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 240ms var(--ease);
}

.progress.is-on { opacity: 1; }

.progress span {
  display: block;
  width: 0; height: 100%;
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: linear-gradient(90deg, var(--amber1), var(--amber2) 55%, var(--accent));
  box-shadow: 0 0 10px rgba(242, 177, 60, 0.75), 0 0 3px rgba(242, 100, 30, 0.5);
  transition: width 180ms var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  /* Still shown, because it carries information, but it stops creeping
     and simply sits while the work happens. */
  .progress span { transition: none; }
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 12px; top: 12px; z-index: 60;
  background: var(--primary); color: var(--on-primary);
  padding: 12px 18px; border-radius: var(--r-pill);
}

:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------------------------------------------------------------- */
/* The canopy: the app's curved header                               */
/* ---------------------------------------------------------------- */

/*
 * A tinted block with faint concentric rings and a curve along its
 * bottom edge, as CurvedHeader draws it. The page title sits on it, so
 * the top of every screen is warm rather than blank.
 */
.canopy {
  position: relative;
  overflow: hidden;
  background: var(--primary-tint);
  padding-top: 20px;
  margin-bottom: 30px;

  /* The sweep is this edge, not a shape drawn over the background. The
     page behind is a gradient, so a curve filled with one flat colour
     leaves a band wherever the gradient has moved on. */
  border-end-start-radius: 46% 36px;
  border-end-end-radius: 46% 36px;
}

.canopy__rings { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.canopy__rings circle { fill: none; stroke: var(--text); stroke-opacity: 0.06; }

.canopy .shell { position: relative; padding-bottom: 46px; }

/* ---------------------------------------------------------------- */
/* Chrome                                                            */
/* ---------------------------------------------------------------- */

.bar { position: sticky; top: 0; z-index: 30; background: var(--primary-tint); }

.bar__in {
  width: 100%; max-width: var(--shell); margin: 0 auto;
  padding-inline: var(--gutter);
  display: flex; align-items: center; gap: 14px; min-height: 60px;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  margin-right: auto; min-width: 0;
  text-decoration: none; color: var(--text);
  font: 800 clamp(13.5px, 3.9vw, 16px)/1 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: -0.4px;
}
.brand__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { width: 30px; height: 30px; flex: none; }

.bar__nav { display: none; gap: 6px; }
.bar__nav a {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 15px; border-radius: var(--r-pill);
  text-decoration: none; color: var(--text-muted);
  font: 600 14px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  transition: background var(--quick) var(--ease), color var(--quick) var(--ease);
}
.bar__nav a:hover { color: var(--text); }
.bar__nav a[aria-current] { background: var(--surface); color: var(--text); box-shadow: var(--lift-resting); }

@media (min-width: 720px) { .bar__nav { display: flex; } }

.leave {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 0; border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary);
  font: 600 13px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--lift-resting);
  transition: transform var(--quick) var(--ease);
}
.leave:hover { transform: translateY(-1px); }
.leave .icon { width: 18px; height: 18px; }
.leave__label { white-space: nowrap; }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  box-shadow: var(--lift-nav);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  min-height: 58px; display: grid; place-items: center; gap: 3px; align-content: center;
  text-decoration: none; color: var(--text-faint);
  font: 600 12.5px/1.2 'Plus Jakarta Sans', system-ui, sans-serif;
  position: relative;
  transition: color var(--quick) var(--ease);
}
.tab .icon { width: 22px; height: 22px; }
.tab[aria-current] { color: var(--accent-deep); }
.tab[aria-current]::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 34px; height: 3px; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--amber1), var(--amber2));
}
@media (min-width: 720px) { .tabs { display: none; } .page { padding-bottom: 48px; } }

/* ---------------------------------------------------------------- */
/* Controls                                                          */
/* ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary);
  font: 600 15px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 0.1px;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  box-shadow: var(--lift-resting);
  transition: transform var(--quick) var(--ease), box-shadow var(--quick) var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--lift-lifted); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.5; box-shadow: none; transform: none; cursor: progress; }

/* Amber is the one saturated surface, and it casts its own colour. */
.btn--amber {
  background: linear-gradient(180deg, var(--amber1), var(--amber2));
  color: var(--on-amber);
  box-shadow: var(--lift-amber);
}
.btn--amber:hover { box-shadow: 0 14px 28px rgba(242, 177, 60, 0.58); }

.btn--secondary { background: var(--secondary); color: #fff; }
.btn--quiet { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn--quiet:hover { box-shadow: var(--lift-resting); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-strong); box-shadow: none; }
.btn--danger { background: var(--danger-tint); color: var(--danger); border-color: transparent; box-shadow: none; }
.btn--full { width: 100%; }
.btn--small { min-height: 40px; padding: 0 16px; font-size: 13.5px; }

.back {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px 0 12px; margin-bottom: 6px;
  border: 0; border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-muted);
  font: 600 13.5px/1 'Plus Jakarta Sans', system-ui, sans-serif; cursor: pointer;
  box-shadow: var(--lift-resting);
}
.back::before { content: '\2190'; font-size: 15px; }
.back:hover { color: var(--text); }

.linkish {
  background: none; border: 0; padding: 6px 0;
  color: var(--accent-deep);
  font: 600 14.5px/1.4 'Plus Jakarta Sans', system-ui, sans-serif;
  cursor: pointer; text-align: start;
}

.icon-btn {
  flex: none; width: 40px; height: 40px;
  border: 0; border-radius: var(--r-pill);
  background: var(--surface-sunken); color: var(--text-faint);
  font-size: 19px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--danger-tint); color: var(--danger); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ---------------------------------------------------------------- */
/* Fields                                                            */
/* ---------------------------------------------------------------- */

.field { margin-bottom: 20px; }
.field label { margin-bottom: 9px; }

.field input, .field textarea, select, .search, .note-input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font: 400 16px/25px 'Atkinson Hyperlegible', Georgia, serif;
  transition: border-color var(--quick) var(--ease), box-shadow var(--quick) var(--ease);
}
.field input:focus, .field textarea:focus, select:focus, .search:focus, .note-input:focus {
  outline: 0;
  border-color: var(--amber2);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.field textarea, .note-input { min-height: 140px; resize: vertical; line-height: 28px; }
.field__hint { margin: 8px 0 0; font-size: 13px; color: var(--text-faint); }
.field__error { margin: 8px 0 0; font-size: 13.5px; color: var(--danger); font-weight: 700; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 21px) calc(50% + 2px), calc(100% - 16px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 46px;
}

.check {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 14px 16px; margin-bottom: 22px;
  border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.check input { margin-top: 3px; flex: none; width: 20px; height: 20px; accent-color: var(--amber2); }
.check strong { display: block; color: var(--text); font: 600 15px/20px 'Plus Jakarta Sans', system-ui, sans-serif; }
.check small { display: block; color: var(--text-faint); font-size: 13px; line-height: 19px; margin-top: 2px; }

/* ---------------------------------------------------------------- */
/* Gate                                                              */
/* ---------------------------------------------------------------- */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 40px var(--gutter) 60px; }
.gate__card {
  width: 100%; max-width: 440px;
  padding: clamp(26px, 5vw, 38px);
  background: var(--surface);
  border-radius: var(--r-2xl);
  box-shadow: var(--lift-lifted);
}
.gate__lede { color: var(--text-muted); margin: 10px 0 28px; font-size: 15px; line-height: 25px; }
.gate__foot { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.gate__lang { margin-top: 24px; }
.gate__demo {
  margin-top: 16px; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--warning-tint); color: var(--warning);
  font: 600 14px/1.4 ui-monospace, Menlo, Consolas, monospace;
}

/* ---------------------------------------------------------------- */
/* Cards                                                             */
/* ---------------------------------------------------------------- */

.card {
  padding: 18px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
}
.card h2 { margin-top: 0; }

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

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

/*
 * Solid marks carry their own fill and stroke per shape, so the sheet
 * must not impose either. --icon-knockout is what the mark is cut out
 * in, and every context that uses one sets it to whatever it sits on.
 */
.icon--solid { fill: currentColor; stroke: none; }

/* ---------------------------------------------------------------- */
/* The focus card: the one thing allowed to be loud                  */
/* ---------------------------------------------------------------- */

.focus {
  position: relative; overflow: hidden;
  width: 100%; display: flex; align-items: center; gap: 16px; text-align: start;
  padding: 22px;
  margin: -14px 0 22px;
  border: 0; border-radius: var(--r-2xl);
  background: linear-gradient(135deg, var(--amber1), var(--amber2) 58%, var(--accent));
  color: var(--on-amber);
  font: inherit; cursor: pointer;
  box-shadow: var(--lift-amber);
  transition: transform var(--quick) var(--ease), box-shadow var(--quick) var(--ease);
}
.focus:hover { transform: translateY(-3px); box-shadow: 0 18px 34px rgba(242, 177, 60, 0.55); }

.focus__rings {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.26) 0 34px, transparent 35px),
    radial-gradient(circle at 96% 72%, rgba(255, 255, 255, 0.16) 0 62px, transparent 63px),
    radial-gradient(circle at 12% 96%, rgba(58, 42, 8, 0.1) 0 44px, transparent 45px);
  pointer-events: none;
}

.focus__body { position: relative; display: grid; gap: 5px; flex: 1; min-width: 0; }
.focus__kicker {
  font: 700 11.5px/16px 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 1.1px; text-transform: uppercase; opacity: 0.78;
}
.focus__title { font: 700 22px/28px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.3px; }
.focus__meta { font-size: 13.5px; opacity: 0.82; }
.focus__track { height: 7px; margin-top: 7px; border-radius: var(--r-pill); background: rgba(58, 42, 8, 0.18); overflow: hidden; }
.focus__fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--on-amber); transition: width var(--calm) var(--ease); }

.focus__go {
  position: relative; flex: none;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: rgba(255, 255, 255, 0.4); color: var(--on-amber);
}
.focus__go .icon { width: 22px; height: 22px; stroke-width: 2; }

/* ---------------------------------------------------------------- */
/* Tiles                                                             */
/* ---------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.tile {
  display: grid; gap: 3px; justify-items: center; text-align: center;
  padding: 16px 8px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
}
.tile__icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: var(--primary-tint); color: var(--accent-deep);
  margin-bottom: 4px;
  --icon-knockout: var(--primary-tint);
}
.tile__n { font: 700 20px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text); }
.tile__label {
  font: 600 11px/14px 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-faint);
}

/* ---------------------------------------------------------------- */
/* A week of check-ins                                               */
/* ---------------------------------------------------------------- */

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; align-items: end; margin: 6px 0 4px; }
.week__day { display: grid; gap: 6px; justify-items: center; }
.week__bar {
  width: 100%; max-width: 34px; height: 76px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  display: flex; align-items: flex-end; overflow: hidden;
}
.week__fill {
  width: 100%; border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--tertiary-soft), var(--tertiary));
  transition: height var(--calm) var(--ease);
}
.week__label { font: 600 11px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text-faint); }
.week__day--none .week__bar { border: 1px dashed var(--border-strong); background: transparent; }

/* ---------------------------------------------------------------- */
/* Badges                                                            */
/* ---------------------------------------------------------------- */

.badges { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; margin: 0; padding: 0; }
.badges li {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 15px 9px 11px;
  border-radius: var(--r-pill);
  background: var(--success-tint); color: var(--success);
  font: 600 13.5px/1 'Plus Jakarta Sans', system-ui, sans-serif;
}
.badges .icon { width: 19px; height: 19px; }
.badges li { --icon-knockout: var(--success-tint); }
.badges li.is-locked { background: var(--surface-sunken); color: var(--text-faint); --icon-knockout: var(--surface-sunken); }

/* ---------------------------------------------------------------- */
/* Learn                                                             */
/* ---------------------------------------------------------------- */

.meter {
  display: flex; align-items: center; gap: 18px;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
  margin-bottom: 26px;
}
.meter__ringwrap { position: relative; display: grid; place-items: center; flex: none; }
.meter__ring { width: 68px; height: 68px; transform: rotate(-90deg); }
.meter__ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.meter__track { stroke: var(--surface-sunken); }
.meter__fill { stroke: var(--amber2); transition: stroke-dasharray var(--calm) var(--ease); }
.meter__pct { position: absolute; font: 700 15px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text); }
.meter__label { margin: 0; font-size: 15px; line-height: 22px; color: var(--text); font-weight: 600; }
.meter__sub { margin: 4px 0 0; font-size: 13.5px; color: var(--text-faint); }

.levels, .lessons, .entries, .plain, .checkins, .bars { list-style: none; margin: 0; padding: 0; }
.levels li, .lessons li, .entries li { margin-bottom: 12px; }

.level, .lesson-row, .entry {
  width: 100%; display: flex; gap: 16px; align-items: center; text-align: start;
  padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--r-xl);
  background: var(--surface); color: inherit; font: inherit; cursor: pointer;
  box-shadow: var(--lift-resting);
  transition: transform var(--quick) var(--ease), box-shadow var(--quick) var(--ease);
}
.level:hover, .lesson-row:hover, .entry:hover { transform: translateY(-2px); box-shadow: var(--lift-lifted); }

.level__n {
  flex: none; width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--amber1), var(--amber2));
  color: var(--on-amber);
  font: 700 17px/1 'Plus Jakarta Sans', system-ui, sans-serif;
}
.level__body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.level__name { font: 600 17px/23px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.1px; color: var(--text); }
.level__note, .lesson-row__sub { color: var(--text-muted); font-size: 13.5px; line-height: 20px; }
.level__state { margin-top: 2px; }
.level__track { height: 5px; margin: 7px 0 4px; border-radius: var(--r-pill); background: var(--surface-sunken); overflow: hidden; }
.level__fill { display: block; height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--amber1), var(--amber2)); transition: width var(--calm) var(--ease); }
.level__go {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: var(--primary-tint); color: var(--text-muted);
}
.level:hover .level__go { background: var(--amber2); color: var(--on-amber); }
.level__done {
  flex: none; align-self: center;
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--success-tint); color: var(--success);
  --icon-knockout: var(--success-tint);
}
.level__done .icon { width: 26px; height: 26px; }

.level__badge { --icon-knockout: var(--success-tint); }
.level__badge .icon { width: 24px; height: 24px; }
.level__badge {
  flex: none; align-self: center;
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--success-tint); color: var(--success);
}

.lesson-row__n {
  flex: none; width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--primary-tint); color: var(--text);
  font: 600 14px/1 'Plus Jakarta Sans', system-ui, sans-serif;
}
.lesson-row__body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.lesson-row__title { color: var(--text); font: 600 15.5px/22px 'Plus Jakarta Sans', system-ui, sans-serif; }
.chip {
  flex: none; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--surface-sunken); color: var(--text-faint);
  font: 600 11px/1 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* The reader */
.reader__bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.reader { max-width: 66ch; }
.reader__body { margin-top: 26px; font-size: 17px; line-height: 30px; color: var(--primary-soft); }
.reader__body p { margin: 0 0 1.1em; }
.reader__body h2 { font-size: 20px; line-height: 27px; margin: 1.7em 0 0.5em; }
.reader__body h3 { font-size: 17px; margin: 1.5em 0 0.4em; }
.reader__body ul, .reader__body ol { padding-inline-start: 1.3em; margin: 0 0 1.1em; }
.reader__body li { margin-bottom: 0.5em; }
.reader__body blockquote {
  margin: 1.4em 0; padding: 16px 20px;
  background: var(--primary-tint); border-radius: var(--r-lg);
  color: var(--text); font-size: 17px;
}

.note { margin: 28px 0; padding: 18px; background: var(--primary-tint); border-radius: var(--r-xl); }
.note h3 { margin-bottom: 6px; }
.note p:last-child { margin-bottom: 0; }

.notice {
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--warning-tint); color: var(--warning);
  font-size: 13.5px; font-weight: 600;
}

.listen {
  margin: 24px 0; padding: 16px 18px;
  background: var(--secondary-tint); border-radius: var(--r-xl);
  display: grid; gap: 12px;
}
.listen__label { margin: 0; font-size: 14px; color: var(--text); }
.listen audio { width: 100%; height: 40px; }

.scripture { margin: 32px 0; }

.verse {
  margin: 0 0 18px; padding: 20px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
  border-inline-start: 4px solid var(--amber2);
}

.verse blockquote { margin: 0; }

.verse__passage {
  margin: 0;
  color: var(--text);
  font-size: 18px; line-height: 30px;
  font-style: italic;
}

.verse blockquote footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin-top: 12px;
}

.verse__ref {
  font-style: normal;
  font: 700 12px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 1.1px; text-transform: uppercase; color: var(--accent-deep);
}

/* Required by most open Bible licences wherever the text appears. */
.verse__translation { font-size: 12px; color: var(--text-faint); }

.verse__commentary { margin: 16px 0 0; font-size: 15px; line-height: 25px; }

.verse__part { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.verse__part h3 {
  font: 600 11.5px/16px 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 1.1px; text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 9px;
}
.verse__part ul { margin: 0; padding-inline-start: 1.2em; }
.verse__part li { margin-bottom: 7px; }
.verse__part p { margin: 0 0 6px; }

.verse__part--prayer { background: var(--secondary-tint); margin: 18px -20px -20px; padding: 16px 20px 18px; border-top: 0; border-end-start-radius: var(--r-xl); border-end-end-radius: var(--r-xl); }
.verse__part--prayer h3 { color: var(--secondary); }

.verse__care {
  margin-top: 16px; padding: 14px 16px;
  background: var(--warning-tint); border-radius: var(--r-lg);
}
.verse__care h3 {
  font: 700 11.5px/16px 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: 1.1px; text-transform: uppercase; color: var(--warning);
  margin-bottom: 6px;
}
.verse__care p { margin: 0; font-size: 14px; line-height: 22px; color: var(--text); }

/* Quiz */
.quiz .question {
  border: 0; margin: 0 0 16px; padding: 20px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
}
.quiz legend { padding: 0; display: block; width: 100%; }
.quiz legend > span:last-child {
  display: block; color: var(--text); margin-bottom: 14px;
  font: 600 17px/24px 'Plus Jakarta Sans', system-ui, sans-serif;
}
.option {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 14px 16px; margin-bottom: 9px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color var(--quick) var(--ease), background var(--quick) var(--ease);
}
.option:hover { background: var(--surface-subtle); }
.option input { margin-top: 4px; flex: none; width: 19px; height: 19px; accent-color: var(--amber2); }
.option:has(input:checked) { border-color: var(--amber2); background: var(--primary-tint); }

.score {
  display: grid; place-items: center;
  width: 128px; height: 128px; margin: 20px 0 24px;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, var(--amber1), var(--amber2));
  box-shadow: var(--lift-amber);
}
.score strong { font: 800 34px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--on-amber); }

/* ---------------------------------------------------------------- */
/* Journal: the reflective surface, so violet                        */
/* ---------------------------------------------------------------- */

.toolbar { display: flex; gap: 10px; margin-bottom: 22px; }
.search { flex: 1; min-width: 0; }

.entry { display: grid; gap: 5px; border-inline-start: 4px solid var(--secondary-soft); }
.entry__date { color: var(--secondary); }
.entry__title { color: var(--text); font: 600 17px/24px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.1px; }
.entry__peek {
  color: var(--text-muted); font-size: 13.5px; line-height: 21px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------------------------------------------------------------- */
/* Mood: somatic warmth, so coral                                    */
/* ---------------------------------------------------------------- */

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 16px 0 10px; }
.scale__pick {
  display: grid; gap: 5px; justify-items: center;
  padding: 14px 4px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); cursor: pointer;
  transition: transform var(--quick) var(--ease), box-shadow var(--quick) var(--ease), background var(--quick) var(--ease);
}
.scale__pick:hover { transform: translateY(-2px); box-shadow: var(--lift-resting); }
.scale__pick.is-on {
  background: var(--tertiary-tint); border-color: var(--tertiary);
  box-shadow: 0 8px 18px rgba(232, 132, 107, 0.3);
}
.scale__face { width: 30px; height: 30px; display: block; }
.scale__face circle { fill: none; stroke: var(--tertiary); stroke-width: 1.7; }
.scale__face path { fill: none; stroke: var(--tertiary); stroke-width: 1.7; stroke-linecap: round; }
.scale__face .eye { fill: var(--tertiary); stroke: none; }
.scale__label { font: 600 12px/15px 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text); }
.scale__caption { font-size: 11px; line-height: 14px; color: var(--text-faint); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.tag {
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-muted);
  font: 600 14px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: background var(--quick) var(--ease), color var(--quick) var(--ease);
}
.tag:hover { border-color: var(--border-strong); }
.tag.is-on { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: var(--lift-resting); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 24px 0; }
.stat {
  padding: 18px; display: grid; gap: 5px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
}
.stat__n { font: 700 28px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text); letter-spacing: -0.4px; }

.bars li { display: grid; grid-template-columns: 6.5rem 1fr 2rem; gap: 12px; align-items: center; margin-bottom: 10px; font-size: 13.5px; }
.bars__label { color: var(--text); font-weight: 600; }
.bars__track { height: 12px; border-radius: var(--r-pill); background: var(--surface-sunken); overflow: hidden; }
.bars__track span {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--tertiary-soft), var(--tertiary));
  transition: width var(--calm) var(--ease);
}
.bars__n { text-align: end; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.checkins li {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px; margin-bottom: 10px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--lift-resting);
  border-inline-start: 4px solid var(--tertiary-soft);
}
.checkins__score { display: block; font: 600 16px/23px 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--text); margin-top: 3px; }
.checkins__tags { display: block; font-size: 13.5px; color: var(--tertiary); font-weight: 600; }
.checkins__note { margin: 7px 0 0; font-size: 14.5px; line-height: 23px; }

/* ---------------------------------------------------------------- */
/* Profile                                                           */
/* ---------------------------------------------------------------- */

.avatar-row { display: flex; gap: 18px; align-items: center; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/*
 * Hidden to the eye, present to everything else.
 *
 * display: none would be simpler and would break the upload: a file
 * input that is display: none cannot be opened programmatically in
 * Safari or on iOS, and its label would have nothing to point at.
 */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.vh:focus-visible + .btn, .btn.is-busy { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn.is-busy { opacity: 0.6; cursor: progress; }
label.btn { cursor: pointer; }
.avatar {
  flex: none; width: 80px; height: 80px;
  border-radius: var(--r-pill); overflow: hidden;
  background: linear-gradient(180deg, var(--amber1), var(--amber2));
  display: grid; place-items: center;
  box-shadow: var(--lift-amber);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar__initial { font: 800 30px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--on-amber); }

.detail { display: grid; grid-template-columns: auto 1fr; gap: 9px 20px; margin: 20px 0 0; font-size: 14.5px; }
.detail dt { align-self: center; }
.detail dd { margin: 0; color: var(--text); }

.plain li { padding: 13px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.plain li:last-child { border-bottom: 0; }
.serial {
  font: 600 13px/1 ui-monospace, Menlo, Consolas, monospace;
  padding: 8px 13px; border-radius: var(--r-pill);
  background: var(--surface-sunken); color: var(--text-muted);
}

/* ---------------------------------------------------------------- */
/* The lockup, where there is no bar above                           */
/* ---------------------------------------------------------------- */

.lockup {
  display: inline-flex; align-items: center; gap: 11px;
  margin-bottom: 24px;
  color: var(--primary);
  font: 800 17px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: -0.4px;
}
.lockup .mark { width: 36px; height: 36px; }
.lockup span { color: var(--text); }

/* ---------------------------------------------------------------- */
/* Desktop                                                           */
/* ---------------------------------------------------------------- */

/*
 * Up to here the layout is the phone's, because up to here the screen is
 * a phone's. Past it the page stops being a tall column in the middle of
 * an empty desk: the bar turns into a rail down the left, the reading
 * column widens to its own comfortable measure, and the lists that were
 * stacked because there was no room get the room.
 *
 * :has() rather than a class, so nothing in the JavaScript has to know
 * about any of it. The rail only exists when the bar does, which is to
 * say when somebody is signed in; the sign-in screen keeps the whole
 * width to centre itself in.
 */
@media (min-width: 1024px) {
  body:has(#bar:not([hidden])) {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    align-items: start;
  }

  body:has(#bar:not([hidden])) .bar {
    position: sticky;
    top: 0;
    height: 100dvh;
    background: transparent;
    border-inline-end: 1px solid var(--border);
  }

  .bar__in {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    height: 100%;
    max-width: none;
    padding: 26px 20px calc(26px + env(safe-area-inset-bottom, 0px));
  }

  .brand { margin: 0 0 22px; font-size: 17px; padding-inline: 10px; }
  .brand .mark { width: 34px; height: 34px; }

  .bar__nav { display: flex; flex-direction: column; gap: 3px; }
  .bar__nav a { padding: 12px 14px; font-size: 15px; }
  .bar__nav a[aria-current] { background: var(--surface); }

  .leave { margin-top: auto; justify-content: center; min-height: 46px; }

  main { min-width: 0; }

  .shell { max-width: 980px; padding-inline: clamp(28px, 4vw, 56px); }
  .page { padding-bottom: 64px; }

  .canopy { padding-top: 34px; }
  .canopy .shell { padding-bottom: 56px; }
  .canopy h1 { font-size: 34px; line-height: 41px; letter-spacing: -0.6px; }

  /* The lists stop being one long column. */
  .levels, .entries { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .levels li, .entries li { margin: 0; }
  .level, .entry { height: 100%; }

  .lessons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .lessons li { margin: 0; }
  .lesson-row { height: 100%; }

  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .checkins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .checkins li { margin: 0; }

  /* The reader keeps its measure; it is the one thing width would hurt. */
  .reader { max-width: 68ch; }

  .toast { left: auto; right: 32px; bottom: 32px; transform: none; }
}

/*
 * Wider still, and the profile and the check-in stop running down the
 * page one card at a time.
 */
@media (min-width: 1320px) {
  body:has(#bar:not([hidden])) { grid-template-columns: 292px minmax(0, 1fr); }

  .shell { max-width: 1120px; }

  .profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }
  .profile-grid > * { margin-bottom: 0; }
  .profile-grid > .profile-wide { grid-column: 1 / -1; }

  .levels, .entries { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- */
/* States                                                            */
/* ---------------------------------------------------------------- */

.loading { display: flex; align-items: center; gap: 8px; padding: 56px var(--gutter); color: var(--text-faint); }
.loading__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber2); animation: pulse 1.3s ease-in-out infinite; }
.loading__dot:nth-child(2) { animation-delay: 0.18s; }
.loading__dot:nth-child(3) { animation-delay: 0.36s; }
.loading__label { margin-inline-start: 10px; font-size: 14px; }

@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1); } }

.broken { margin: -14px 0 22px; }
.broken code {
  display: inline-block;
  padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--surface-sunken); color: var(--text-muted);
  font: 600 13px/1 ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
}

.empty, .problem {
  padding: 32px 24px; border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--lift-resting);
  text-align: center;
}
.empty h3, .problem h3 { margin-bottom: 8px; }
.empty p, .problem p { color: var(--text-muted); }
.problem { border-top: 4px solid var(--danger); text-align: start; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  max-width: min(520px, calc(100vw - 24px));
  padding: 15px 20px; border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary);
  font: 600 14.5px/1.45 'Plus Jakarta Sans', system-ui, sans-serif;
  box-shadow: var(--lift-lifted);
}
.toast--bad { background: var(--danger); color: #fff; }
@media (min-width: 720px) { .toast { bottom: 28px; } }

.sheet { border: 0; padding: 0; background: transparent; max-width: min(460px, calc(100vw - 24px)); }
.sheet::backdrop { background: var(--overlay); }
.sheet__in {
  padding: 26px;
  background: var(--surface); border-radius: var(--r-2xl);
  box-shadow: var(--lift-lifted); color: var(--text-muted);
}
.sheet__in h2 { margin: 0 0 10px; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

[hidden] { display: none !important; }
