/* Spotlight: a dark plum ledge with one soft pool of light. The pebble and whatever can be touched
   next sit in the light; the corners, and the chrome in them, stay dim. Kit colours and fonts only. */

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

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

body {
  overflow: hidden;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, url("art/ledge-backdrop.jpg"));
  background-size: cover;
  background-position: center;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 18px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The house: corners kept dark until the session ends, then the lights come up. */
.dim,
.house {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  transition: opacity 2400ms ease-in-out;
}
.dim { background: radial-gradient(ellipse 75% 60% at 50% 48%, transparent 38%, color-mix(in srgb, var(--ak-bg) 78%, transparent) 100%); }
.house {
  opacity: 0;
  background: radial-gradient(ellipse 95% 85% at 50% 48%, color-mix(in srgb, var(--ak-ink) 11%, transparent), transparent 78%);
}
body.lights-up .dim { opacity: 0.15; }
body.lights-up .house { opacity: 1; }

.cairn {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 44px);
  left: max(12px, env(safe-area-inset-left));
  z-index: 3;
  width: 56px;
  height: auto;
}
/* A sideways phone has no free corner beside the cards, so its cairn shows at each ending instead,
   and the logo takes the corner a little larger. */
@media (orientation: landscape) and (max-width: 1199px) {
  .cairn { display: none; }
  body .mark { top: max(8px, env(safe-area-inset-top)); width: 84px; }
}

.mark {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 3;
  width: 56px;
  height: auto;
}

/* Close sits under the help button, top right, dim until touched and always readable. */
.close-pill {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 56px);
  right: max(12px, env(safe-area-inset-right));
  z-index: 33;
  min-width: 48px;
  min-height: 48px;
  padding: 0 8px;
  border: 1.5px solid color-mix(in srgb, var(--ak-ink) 22%, transparent);
  border-radius: 999px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  letter-spacing: 0.03em;
}
.close-pill:active,
.close-pill:focus-visible { color: var(--ak-ink); border-color: var(--ak-ink); }

/* The stage: the lit board above its tools when upright, beside them when sideways. */
.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  max-width: 1120px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: safe center;
  justify-items: center;
  gap: clamp(10px, 2dvh, 28px);
  padding:
    max(calc(var(--ac-status-h, 60px) + 8px), calc(env(safe-area-inset-top) + 124px))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow: hidden;
  touch-action: manipulation;
}

/* Only a screen smaller than any phone this is made for may need to scroll. */
@media (orientation: portrait) and (max-height: 700px), (orientation: landscape) and (max-height: 340px) {
  .stage { overflow-y: auto; }
}

.lit {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 100%;
}

.side {
  display: grid;
  justify-items: center;
  width: 100%;
}

/* The pool of light falls on whatever the lit area holds, and it follows the breath. */
.pool {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: calc(100% + 28dvw);
  height: calc(100% + 22dvh);
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--ak-ink) 15%, transparent), color-mix(in srgb, var(--ak-ink) 6%, transparent) 62%, transparent);
  opacity: 0.8;
  pointer-events: none;
  transition: opacity var(--phase-ms, 1200ms) ease-in-out;
}
.stage[data-full="1"] .pool { opacity: 1; }
body.lights-up .pool { opacity: 1; }

.choose-board,
.choose-side,
.oval,
.breathe-side { display: none; }
.stage[data-view="choose"] .choose-board,
.stage[data-view="choose"] .choose-side { display: flex; }
.stage:not([data-view="choose"]) .oval { display: block; }
.stage:not([data-view="choose"]) .breathe-side { display: flex; }

/* The question and its cards. */
.choose-board {
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.2dvh, 12px);
  width: min(100%, 460px);
}

.question {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(22px, 6.6vw, 28px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: center;
}

.last,
.kept {
  margin: 0;
  color: var(--ak-ink-muted);
  font-size: 18px;
  text-align: center;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.1dvh, 10px);
  width: 100%;
  padding: 4px;
  border-radius: 34px;
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  width: 100%;
  min-height: clamp(54px, 7.4dvh, 80px);
  margin: 0;
  padding: 4px 26px 4px 6px;
  border: 2px solid color-mix(in srgb, var(--ak-ink) 26%, transparent);
  border-radius: 28px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  text-align: left;
}
.card-stone { display: grid; place-items: center; }
.card-stone img { display: block; width: 64px; max-height: 50px; object-fit: contain; }
.card-words { display: grid; gap: 0; min-width: 0; }
.card-label {
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 5.2vw, 20px);
  font-weight: 600;
  line-height: 1.2;
}
.card-sub { color: var(--ak-ink-muted); font-size: 18px; line-height: 1.3; }
.card-sub.just { color: var(--ak-ink); }

/* Last time's card: first, a shade brighter, in the painted frame with its thin candle-gold rim. */
.card.lead {
  border: 9px solid transparent;
  border-image: url("art/moment-card.png") 18 / 9px stretch;
  border-radius: 20px;
  background: color-mix(in srgb, var(--ak-surface) 84%, var(--ak-ink));
  background-clip: padding-box;
  padding-block: 0;
}

/* The chosen card: brighter, a firm ink edge, and a small filled stone mark at its right. */
.card[aria-pressed="true"] {
  border-color: var(--ak-ink);
  background-color: color-mix(in srgb, var(--ak-surface) 76%, var(--ak-ink));
}
.card[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  right: 9px;
  top: 50%;
  width: 12px;
  height: 9px;
  translate: 0 -50%;
  border-radius: 50%;
  background: var(--ak-ink);
}

/* The two ways to choose, side by side, the one in use filled so the switch is plain to see. */
.choose-by {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  border: 1.5px solid color-mix(in srgb, var(--ak-ink) 22%, transparent);
  border-radius: 999px;
  background: var(--ak-bg);
}
.by {
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ak-ink-muted);
}
.choose-by-label { padding: 0 6px 0 12px; color: var(--ak-ink-muted); }
.by[aria-pressed="true"] { background: var(--ak-surface); color: var(--ak-ink); box-shadow: inset 0 0 0 1.5px var(--ak-ink); }



/* The tools under (or beside) the board. */
.choose-side {
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.4dvh, 14px);
  width: min(100%, 460px);
}

.ready {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 120px;
  visibility: hidden;
}
.ready.on { visibility: visible; }
.ready:not(.on) { display: none; }

.opening {
  margin: 0;
  max-width: 24em;
  font-family: var(--ak-font-display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
}

.begin {
  min-width: 136px;
  min-height: 56px;
  padding: 0 32px;
  border: 2px solid var(--ak-accent);
  border-radius: 999px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 22px;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.begin:active { background: var(--ak-btn-active); }
.begin-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.guide-begin { padding: 8px 14px 8px 10px; }
.guide-begin svg { rotate: 90deg; }
@media (orientation: landscape) {
  .guide-begin { display: none !important; }
}

/* The cards screen opens by saying what the start screen chose, so it reads as the next step. */
.step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px 8px;
  margin: 0;
  color: var(--ak-ink-muted);
}

/* The screen opens on the painted pebble, breathing slowly, with the title beside it upright and the
   chosen breath's name beside it sideways; the choices follow below. */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.hero-stone {
  display: block;
  width: auto;
  height: clamp(52px, 8.5dvh, 80px);
  max-width: 36vw;
  object-fit: contain;
}
.hero-words { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.hero-title { display: block; width: clamp(96px, 27vw, 136px); height: auto; }
.hero-name {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.25;
}
.hero .step { justify-content: flex-start; flex-wrap: wrap; }
.hero-side { display: none; }
@media (orientation: landscape) {
  .hero-board { display: none; }
  .hero-side { display: flex; }
  .hero-side .hero-stone { height: clamp(44px, 15dvh, 72px); }
}
/* Upright the title leads the screen, so the corner logo steps aside there and the cairn takes the corner. */
@media (orientation: portrait) {
  body[data-view="choose"] .mark { display: none; }
  body[data-view="choose"] .cairn { top: max(12px, env(safe-area-inset-top)); }
}

.soft-link {
  min-height: 48px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ak-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.tools,
.breathe-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.tool,
.soft {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 48px;
  min-height: 48px;
  padding: 0 13px;
  border: 1.5px solid color-mix(in srgb, var(--ak-ink) 20%, transparent);
  border-radius: 999px;
  background: var(--ak-surface);
  color: var(--ak-ink-muted);
}
.tool svg { width: 20px; height: 20px; flex: none; }

.tool-state { min-width: 1.6em; text-align: left; }
.tool[aria-pressed="true"] { color: var(--ak-ink); border-color: color-mix(in srgb, var(--ak-ink) 60%, transparent); }
.tool:active, .soft:active, .tool:focus-visible, .soft:focus-visible { color: var(--ak-ink); }

/* Teaching: on a solid backing, in flow, beside what it points at and never over it. */
.guide {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  margin: 0;
  padding: 10px 18px;
  border: 1.5px solid color-mix(in srgb, var(--ak-ink) 45%, transparent);
  border-radius: 22px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 18px;
  line-height: 1.35;
}
.guide svg { flex: none; width: 24px; height: 24px; }
.guide-side { display: none; }
@media (orientation: portrait) {
  .guide-side { display: none !important; }
}
@media (orientation: landscape) {
  .guide-board { display: none !important; }
  .guide-side { display: flex; }
  .guide-side:not(.to-begin) svg { rotate: 90deg; }
}
.ring { box-shadow: 0 0 0 3px var(--ak-ink); }

/* The breathing oval: a painted pebble, sized from both width and height. */
.oval {
  --ratio: 3.31;
  width: min(78dvw, calc(44dvh * var(--ratio)), 600px);
  aspect-ratio: var(--ratio);
}
.oval[data-pebble="lavender"] { --ratio: 3.31; }
.oval[data-pebble="slate"] { --ratio: 1.15; }
.oval[data-pebble="sage"] { --ratio: 1.255; }
.pebble {
  display: block;
  width: 100%;
  height: 100%;
  transform: scale(0.62);
  transform-origin: 50% 50%;
}

.breathe-side {
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(100%, 460px);
}

.phase {
  position: relative;
  width: 100%;
  height: 48px;
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 32px;
  font-weight: 500;
  line-height: 48px;
  letter-spacing: 0.06em;
  text-align: center;
}
.phase .word {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 600ms ease-in-out;
}
/* The old word is gone before the new one arrives, so two words never show at once. */
.phase .word.on { opacity: 1; transition-delay: 600ms; }

.progress {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: min(100%, 260px);
}
.progress-track {
  position: relative;
  display: block;
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ak-ink-muted) 28%, transparent);
}
.progress-fill {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: var(--ak-ink-muted);
  transform: scaleX(0);
  transform-origin: left center;
}
.progress-text { color: var(--ak-ink-muted); font-size: 18px; }
.stage[data-view="end"] .progress { display: none; }

.closing {
  margin: 0;
  max-width: 22em;
  font-family: var(--ak-font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transition: opacity 1600ms ease-in-out;
}
.stage[data-view="end"] .closing { opacity: 1; }
.stage.handed .closing { opacity: 0; }
.stage[data-view="end"] .phase,
.stage[data-view="end"] .breathe-tools,
.stage[data-view="end"] .sound-tools { display: none; }
.stage[data-view="breathe"] .closing { display: none; }

.pause {
  min-width: 132px;
  min-height: 52px;
  padding: 0 30px;
  border: 1.5px solid var(--ak-accent);
  border-radius: 999px;
  background: var(--ak-surface);
  color: var(--ak-ink-muted);
  letter-spacing: 0.04em;
}
.pause:active, .pause:focus-visible { color: var(--ak-ink); }

/* Sideways: the lit board on one side, the tools and words on the other. */
@media (orientation: landscape) {
  .stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(16px, 4dvw, 48px);
    padding-top: calc(var(--ac-status-h, 60px) + 4px);
    padding-right: calc(max(16px, env(safe-area-inset-right)) + 64px);
  }
  .oval { width: min(46dvw, calc((100dvh - var(--ac-status-h, 60px) - 48px) * var(--ratio)), 600px); }
  .question { font-size: clamp(22px, 6dvh, 28px); }
  .card { min-height: clamp(52px, 13dvh, 80px); }
  .card-stone img { max-height: 42px; }
  .card-label { font-size: 19px; }
  .cards { gap: 4px; padding: 3px; }
  .ready { min-height: 0; gap: 6px; }
  .ready:not(.on) { display: none; }
  .choose-board,
  .choose-side { gap: clamp(6px, 1.6dvh, 14px); }
  .tool { padding: 0 10px; gap: 4px; }
  .stage[data-view="choose"] .side {
    align-self: stretch;
    align-content: center;
    padding-left: clamp(16px, 4dvw, 40px);
    border-left: 1.5px solid color-mix(in srgb, var(--ak-ink) 18%, transparent);
  }
  .guide-side { padding: 4px 12px; }
}

/* A shorter upright phone: a little less air between the parts. */
@media (orientation: portrait) and (max-height: 820px) {
  .stage { gap: 6px; }
  .choose-board,
  .choose-side { gap: 5px; }
}

/* The narrowest phones: the length pills keep to one row. */
@media (max-width: 380px) {
  .tool { padding: 0 10px; gap: 4px; }
}

/* A short landscape phone: the opening line and the guide get a little tighter. */
@media (orientation: landscape) and (max-height: 430px) {
  .opening { font-size: 19px; }
  .guide { padding: 6px 14px; }
  .begin { min-height: 52px; }
  .question { font-size: 24px; }
}

/* The ending sits beside the settled pebble, never over it: below it when upright, to its right when
   sideways. No wash, so the lit stage and the pebble stay in full view; the card itself is solid.
   The chrome adds its sheet after this one, so these overrides start from body to win. */
body #activity-chrome-ending.site-insighfulness {
  justify-content: flex-end;
  padding: 0 16px calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  background: none;
}
body #activity-chrome-ending.site-insighfulness .ac-card {
  width: min(92vw, 420px);
  height: min(320px, calc(100dvh - 460px));
  aspect-ratio: auto;
  gap: 8px;
  padding: 20px 44px;
}
body #activity-chrome-ending.site-insighfulness .ac-verdict { font-size: 20px; }
body #activity-chrome-ending.site-insighfulness .ac-lines { font-size: 18px; }
body #activity-chrome-ending.site-insighfulness .ac-work { order: -1; width: 92px; max-width: none; }
body #activity-chrome-ending.site-insighfulness .ac-work img { width: 92px; height: auto; border-radius: 0; }
body #activity-chrome-ending.site-insighfulness .ac-actions { top: calc(100% + 12px); }
body #activity-chrome-ending.site-insighfulness .ac-replay { box-shadow: inset 0 0 0 2px var(--ak-accent); }
.stage[data-view="end"] { align-content: start; }

@media (orientation: landscape) {
  body #activity-chrome-ending.site-insighfulness {
    align-items: flex-end;
    justify-content: flex-start;
    padding: calc(var(--ac-status-h, 60px) + 4px) calc(max(16px, env(safe-area-inset-right)) + 72px) 0 0;
  }
  body #activity-chrome-ending.site-insighfulness .ac-card {
    width: min(46vw, 420px);
    height: calc(100dvh - var(--ac-status-h, 60px) - 80px);
    padding: 12px 36px;
    border-radius: 72px;
  }
  body #activity-chrome-ending.site-insighfulness .ac-work,
  body #activity-chrome-ending.site-insighfulness .ac-work img { width: 72px; }
  .stage[data-view="end"] { align-content: center; }
}

/* Every movement is slow, and only when motion is welcome. With less motion it all fades instead. */
@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .stage.arrive .lit,
  :root:not(.ac-still) .stage.arrive .side,
  :root:not(.ac-still) .cards.arrive { animation: arrive 900ms ease-out both; }
  :root:not(.ac-still) .pool { transition: opacity var(--phase-ms, 1200ms) ease-in-out, scale 2400ms ease-in-out; }
  :root:not(.ac-still) body.lights-up .pool { scale: 1.7; }
  :root:not(.ac-still) .card,
  :root:not(.ac-still) .tool { transition: background-color 700ms ease, border-color 700ms ease, color 700ms ease; }
  :root:not(.ac-still) .ring { animation: ring 2000ms ease-in-out infinite; }
  :root:not(.ac-still) .hero-stone { animation: idle-breath 5000ms ease-in-out infinite alternate; }

  @keyframes idle-breath { from { scale: 0.88; } to { scale: 1; } }

  @keyframes arrive { from { opacity: 0; } to { opacity: 1; } }
  @keyframes ring {
    0%, 100% { box-shadow: 0 0 0 3px var(--ak-ink); }
    50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--ak-ink) 30%, transparent); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .pebble { transform: scale(0.82) !important; }
}
