/* The calm door (Oct 16, Abe's call), v2: less on screen.
   One ground, type and hairlines, no cards, no tracked capitals.
   The door is pine; the five questions are paper with the answers
   docked at the thumb. Same Instrument Serif as the rest of the Atlas. */

.calm {
  position: fixed;
  inset: 0;
  z-index: 340;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  opacity: 0;
  transition: opacity .25s ease;
}
.calm.is-in { opacity: 1; }
.calm.is-solid { transition: none; }

/* before the first paint: the room behind the door stays dark until the
   door is up, so nothing flashes on launch (index.html sets this) */
html.calm-veil body { background: var(--pine); }
html.calm-veil #appShell, html.calm-veil #barSummon, body.calm-open #barSummon { visibility: hidden; }
/* "Hey, <name>" hands over to the door with a plain fade */
.arrival-gate.is-handoff { opacity: 0 !important; transition: opacity .7s ease !important; pointer-events: none; }

/* ---------- the living ground ----------
   A blurred harbor at sunset (G. Baker, New York Harbor with Brooklyn
   Bridge, after 1869, the Met, CC0) under the pine, drifting slowly, and
   three soft lights that wander. Transform and opacity only. */
.calm { background: var(--pine); }
.calm-ground { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: var(--pine); }
body.is-demo .calm-ground { top: 32px; }
.calm-ground-img {
  position: absolute; inset: -10%;
  background: url("harbor-blur.jpg") center 40% / cover no-repeat;
  opacity: 0;
  transition: opacity 1.6s ease;
  transform: scale(1.06);
  animation: calm-drift 56s ease-in-out infinite alternate;
  will-change: transform;
}
.calm-ground-wash {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgb(30 52 44 / .18) 0%, rgb(34 54 42 / .42) 38%, rgb(40 56 40 / .82) 72%, rgb(44 58 42 / .94) 100%);
}
/* the door keeps its own greens in either look; the theme's pine flips
   in dark and washed the harbor out to beige */
.calm, .calm-ground { background: #2c3a2a; }
html[data-dark] .calm, html[data-dark] .calm-ground { background: #161d15; }
html[data-dark] .calm-ground-wash { background: linear-gradient(180deg, rgb(22 29 21 / .45) 0%, rgb(22 29 21 / .7) 45%, rgb(22 29 21 / .92) 100%); }
.calm-ground.has-img .calm-ground-img { opacity: .92; }
html[data-dark] .calm-ground.has-img .calm-ground-img { opacity: .7; }
.calm-inner--door, .calm-inner--door .calm-top { color: #f2efe6; }
.calm-orb {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  opacity: .22; will-change: transform;
}
.calm-orb--a { left: -20vmax; top: -24vmax; background: radial-gradient(closest-side, rgb(228 205 142 / .9), transparent); animation: calm-wander-a 38s ease-in-out infinite alternate; }
.calm-orb--b { right: -30vmax; top: 10vh; background: radial-gradient(closest-side, rgb(214 140 96 / .7), transparent); animation: calm-wander-b 47s ease-in-out infinite alternate; }
.calm-orb--c { left: 10vw; bottom: -40vmax; background: radial-gradient(closest-side, rgb(var(--leaf-rgb) / .9), transparent); opacity: .3; animation: calm-wander-c 61s ease-in-out infinite alternate; }
@keyframes calm-drift { from { transform: scale(1.06) translate3d(-1.5%, 0, 0); } to { transform: scale(1.16) translate3d(2%, -2%, 0); } }
@keyframes calm-wander-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(18vw, 12vh, 0); } }
@keyframes calm-wander-b { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-16vw, 18vh, 0); } }
@keyframes calm-wander-c { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(14vw, -14vh, 0); } }
.calm-stage { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }
.calm-stage > .calm-inner { flex: 1; }
body.calm-open { overflow: hidden; }
body.is-demo .calm { top: 32px; }

:where(.calm) :is(p, h1, dd, span) { text-wrap: pretty; }
.calm h1 { text-wrap: balance; }
:where(.calm) button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.calm :focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.calm-arrow { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.calm-inner { min-height: 100%; display: flex; flex-direction: column; }
.calm-inner--door { background: transparent; color: var(--pine-ink); }
.calm-inner--sheet { background: color-mix(in srgb, var(--paper) 94%, transparent); }
.calm-inner--sheet .calm-top { background: color-mix(in srgb, var(--pine) 88%, transparent); }

/* ---------- top line ---------- */
.calm-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px;
  padding: max(10px, env(safe-area-inset-top)) clamp(20px, 4vw, 56px) 10px;
  background: transparent; color: var(--pine-ink);
}
.calm-brand { display: inline-flex; align-items: center; gap: 10px; font: 400 20px/1 var(--serif); opacity: .9; }
.calm-brand svg { width: 24px; height: 24px; }
.calm-back {
  appearance: none; border: 0; background: none; cursor: pointer;
  width: 44px; height: 44px; margin-left: -12px; display: grid; place-items: center; border-radius: 50%;
}
.calm-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.calm-back:hover { background: rgb(var(--pine-ink-rgb) / .1); }

.calm-dots { display: inline-flex; gap: 6px; align-items: center; }
.calm-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.25px solid currentColor; opacity: .55;
  transition: background .2s ease, transform .2s ease, opacity .2s ease;
}
.calm-dots i.is-set { background: currentColor; opacity: 1; }
.calm-dots i.is-working { background: linear-gradient(90deg, currentColor 50%, transparent 50%); opacity: 1; }
.calm-dots i.is-help { background: var(--gilt); border-color: var(--gilt); opacity: 1; }
.calm-dots i.is-here { transform: scale(1.4); opacity: 1; }

/* ---------- the door ---------- */
.calm-hero { padding: clamp(28px, 6vh, 72px) clamp(20px, 4vw, 56px) 8px; }
.calm-when { margin: 0 0 10px; font-size: 14px; line-height: 1.3; opacity: .88; } /* QA Nov 11: .7 fell to 2.7:1 over the sky on phones */
.calm-inner--door .calm-hero { text-shadow: 0 1px 3px rgb(20 28 20 / .55), 0 1px 24px rgb(20 28 20 / .55); }
.calm-title { margin: 0; font: 400 clamp(48px, 12vw, 120px)/.95 var(--serif); letter-spacing: -.01em; }
.calm-news {
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left;
  display: flex; gap: 12px; align-items: baseline;
  margin-top: 22px; padding: 6px 0; max-width: 34em;
  font-size: 16px; line-height: 1.45; color: rgb(var(--pine-ink-rgb) / .94);
}
.calm-news b { font-weight: 600; color: var(--pine-ink); }
.calm-news-line.is-new { animation: calm-rise .35s cubic-bezier(.2, .8, .2, 1); }
.calm-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--gilt); transform: translateY(-2px); animation: calm-glow 4s ease-in-out infinite; }
@keyframes calm-glow { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.calm-ways {
  display: flex; flex-direction: column;
  padding: 28px clamp(20px, 4vw, 56px) max(24px, env(safe-area-inset-bottom));
  margin-top: auto;
}
.calm-way {
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 14px;
  min-height: 62px; padding: 12px 0;
  border-top: 1px solid rgb(var(--pine-ink-rgb) / .16);
  font: 400 26px/1.15 var(--serif);
  transition: color .15s ease;
}
.calm-way:last-child { border-bottom: 1px solid rgb(var(--pine-ink-rgb) / .16); }
.calm-way > span:first-child { flex: 1; }
.calm-way small {
  display: block; margin-top: 5px; max-width: 30em;
  font: 400 14px/1.4 var(--sans); color: rgb(var(--pine-ink-rgb) / .72);
}
.calm-way--lit { padding: 16px 0; }

/* say it instead */
.calm-voice {
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 14px;
  margin-top: 18px; padding: 6px 0; min-height: 56px;
  font: 400 21px/1.15 var(--serif); color: var(--pine-ink);
}
.calm-voice small { display: block; margin-top: 3px; font: 400 14px/1.4 var(--sans); color: rgb(var(--pine-ink-rgb) / .72); }
.calm-mic {
  position: relative; flex: none; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gilt); color: var(--pine);
}
.calm-mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.calm-mic::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid var(--gilt);
  animation: calm-breathe 3.6s ease-out infinite;
}
@keyframes calm-breathe { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(1.55); opacity: 0; } }
.calm-voice:active .calm-mic { transform: scale(.94); }
.calm-mic { transition: transform .15s ease; }
.calm-way .calm-arrow { opacity: .5; transition: transform .2s ease, opacity .2s ease; }
.calm-way:hover .calm-arrow, .calm-way:active .calm-arrow { transform: translateX(4px); opacity: 1; }
.calm-way--lit { color: var(--gilt); }
.calm-way--lit .calm-arrow { opacity: 1; }
.calm-way--quiet { color: rgb(var(--pine-ink-rgb) / .62); }

/* ---------- the sheets: need, the five questions, done ---------- */
.calm-sheet {
  flex: 1;
  padding: clamp(24px, 5vh, 56px) clamp(20px, 4vw, 56px) 24px;
  display: grid; align-content: start; gap: 18px;
}
.calm-sheet .calm-when { color: var(--muted); opacity: 1; margin-bottom: 6px; }
.calm-h { margin: 0; font: 400 clamp(34px, 7vw, 64px)/1.02 var(--serif); }
.calm-sub { margin: 10px 0 0; color: var(--muted); font-size: 16px; line-height: 1.45; }
.calm-step-facts { display: grid; gap: 14px; }

.calm-ways--sheet { padding: 0; margin: 0; }
.calm-ways--sheet .calm-way { border-color: var(--line); font-size: 23px; min-height: 58px; }

.calm-facts { margin: 0; display: grid; }
.calm-facts > div {
  display: grid; grid-template-columns: 5.6em minmax(0, 1fr); gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.calm-facts > div:last-child { border-bottom: 1px solid var(--line); }
.calm-facts dt { font-size: 14px; line-height: 1.45; color: var(--muted); }
.calm-facts dd { margin: 0; font-size: 16px; line-height: 1.45; }
.calm-facts a, .calm-route a { color: var(--leaf); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.calm-mine { margin: 0; font-size: 15px; line-height: 1.45; color: var(--amber); }
.calm-copy {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 6px 0; justify-self: start;
  font-size: 15px; font-weight: 600; color: var(--leaf); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.calm-route { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; animation: calm-rise .25s ease; }
.calm-route p { margin: 0; font-size: 14px; line-height: 1.4; color: var(--muted); flex: 1 1 14em; }
.calm-route button, .calm-left-go {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 6px 0;
  display: inline-flex; align-items: center; gap: 8px;
  font: 400 21px/1.2 var(--serif); color: var(--leaf);
}
.calm-dock .calm-route { grid-column: 1 / -1; }

/* the answers, docked at the thumb */
.calm-dock {
  position: sticky; bottom: 0;
  display: grid; gap: 10px;
  padding: 12px clamp(20px, 4vw, 56px) max(16px, env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.calm-answer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.calm-answer button {
  appearance: none; cursor: pointer;
  min-height: 50px; padding: 10px 6px; border-radius: 12px;
  border: 1px solid rgb(var(--ink-rgb) / .16); background: transparent;
  font-size: 15px; font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.calm-answer button:hover { border-color: rgb(var(--ink-rgb) / .4); }
.calm-answer button:active { transform: scale(.97); }
.calm-answer button { transition: background .2s ease, color .2s ease, border-color .2s ease, transform .12s ease; }
.calm-answer button.is-on { background: var(--pine); border-color: var(--pine); color: var(--pine-ink); }
.calm-answer button[data-ans="help"].is-on { background: var(--amber); border-color: var(--amber); color: #fff; }
.calm-next {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border-radius: 12px;
  background: var(--pine); color: var(--pine-ink); font-size: 16px; font-weight: 600;
}

/* done: only what's left */
.calm-left { display: grid; }
.calm-left-row { display: grid; gap: 2px; justify-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.calm-left-row:last-child { border-bottom: 1px solid var(--line); }
.calm-left-q {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 0;
  font-size: 14px; color: var(--amber);
}
.calm-left-row p { margin: 0; font-size: 16px; line-height: 1.45; }

/* the way back from the full Atlas */
.calm-return {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; margin-right: 6px;
}
.calm-return svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.calm-return:hover { border-color: var(--leaf); }

@keyframes calm-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- wide: two sides, so nothing sits in a strip ---------- */
@media (min-width: 900px) {
  .calm-inner--door { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .calm-inner--door .calm-top { grid-column: 1 / -1; }
  .calm-inner--door .calm-hero { align-self: center; padding-bottom: 80px; }
  .calm-inner--door .calm-ways { align-self: center; margin: 0; padding-bottom: 80px; padding-right: clamp(32px, 6vw, 120px); }
  .calm-way { font-size: 30px; min-height: 76px; }

  .calm-split {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    column-gap: clamp(48px, 6vw, 120px);
    align-items: start;
    padding-top: clamp(40px, 9vh, 96px);
  }
  .calm-split > :first-child { position: sticky; top: 24px; }
  .calm-sheet { align-content: center; padding-bottom: 8vh; }
  .calm-h { font-size: clamp(40px, 4.4vw, 76px); }
  .calm-facts dt { font-size: 15px; }
  .calm-facts dd, .calm-left-row p { font-size: 18px; }
  .calm-facts > div { padding: 14px 0; }
  .calm-ways--sheet .calm-way { font-size: 26px; }
  .calm-dock {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    column-gap: clamp(48px, 6vw, 120px);
    align-items: center;
  }
  .calm-dock .calm-answer { grid-column: 1; }
  .calm-dock .calm-next { grid-column: 2; justify-self: end; }
  .calm-dock .calm-next:only-child { grid-column: 1 / -1; }
}
@media (min-width: 1400px) {
  .calm-hero, .calm-sheet, .calm-top, .calm-dock { padding-left: clamp(56px, 7vw, 140px); padding-right: clamp(56px, 7vw, 140px); }
}

/* short phones: tighten the door so the four ways sit on one screen */
@media (max-width: 520px) {
  .calm-hero { padding-top: 18px; }
  .calm-ways { padding-top: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .calm-way { min-height: 54px; padding: 9px 0; font-size: 24px; }
  .calm-way--lit { padding: 12px 0; }
  .calm-voice { margin-top: 8px; }
  .calm-news { margin-top: 14px; }
}
@media (max-height: 700px) and (max-width: 520px) {
  .calm-title { font-size: 44px; }
  .calm-facts > div { padding: 9px 0; }
}

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

/* "Hey, <name>" gets the skyline behind its wash too (Mike, Nov 11: "a bg image behind the wash
   here as well"): the same Manhattan-from-Greenpoint photo as Now's header (Kidfly182, Wikimedia
   Commons, CC BY 4.0). Darkest where the words sit, opening toward the edges. Fixed greens, so
   dark mode can't wash it to beige. */
.arrival-gate {
  background:
    radial-gradient(ellipse 60% 55% at 50% 52%, rgb(36 50 36 / .9) 0%, rgb(40 54 40 / .8) 55%, rgb(44 58 42 / .66) 100%),
    url("skyline.jpg") 50% 46% / cover no-repeat,
    #2c3a2a;
}
html[data-dark] .arrival-gate {
  background:
    radial-gradient(ellipse 60% 55% at 50% 52%, rgb(18 24 17 / .92) 0%, rgb(20 27 19 / .8) 55%, rgb(22 29 21 / .62) 100%),
    url("skyline.jpg") 50% 46% / cover no-repeat,
    #161d15;
}
.arrival-gate .arrival-hello, .arrival-gate .arrival-line { text-shadow: 0 1px 3px rgb(20 28 20 / .5), 0 1px 24px rgb(20 28 20 / .5); }
.arrival-gate::before, .arrival-gate::after { border-color: rgb(242 239 230 / .16); }
.arrival-gate .arrival-credit { position: absolute; right: 14px; bottom: 10px; z-index: 1; margin: 0; font: 500 10px/1 var(--sans); letter-spacing: .02em; color: #f2efe6; opacity: .5; }
.arrival-gate .arrival-line { color: rgb(242 239 230 / .8); }
.arrival-gate .arrival-credit { opacity: .7; }
.arrival-enter:focus-visible { border-radius: 999px; }
