/* ==========================================================================
   Dusk — exercise chrome (periphery / between / two / contact / clearing / grip / shift)

   The governing rule: the practice object owns the screen. All chrome sits at
   <=42% opacity, and there are no progress numerals, no percentage and no timer
   digits anywhere — rounds read as tick marks. A patient mid-exercise should not
   be able to read a number that invites them to evaluate their performance.

   The live practice object is the <canvas>; the halo and rings beneath it are
   CSS, so the canvas clears transparently (see exercise-core.js).
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Tokens live in tokens.css, linked ahead of this file. */

@keyframes lift {
  from { opacity: 0.3; }
  to   { opacity: 0.85; }
}
@keyframes widen {
  from { transform: scaleX(0.9); opacity: 0.45; }
  to   { transform: scaleX(1.06); opacity: 0.92; }
}

html, body { height: 100%; }
body {
  background: var(--night);
  color: var(--night-ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* --- Grounds, one per exercise --- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
body.ex-periphery .stage { background: radial-gradient(ellipse at 50% 50%, #101A1D 0%, #0E1316 58%, #0B0C10 100%); }
body.ex-grip .stage      { background: radial-gradient(ellipse at 50% 50%, #1C1315 0%, #131013 58%, #0B0C10 100%); }
body.ex-between .stage   { background: radial-gradient(ellipse at 50% 50%, #12161A 0%, #0F1216 58%, #0B0C10 100%); }
body.ex-two .stage       { background: radial-gradient(ellipse at 50% 50%, #16130E 0%, #100F12 58%, #0B0C10 100%); }
body.ex-contact .stage   { background: radial-gradient(ellipse at 50% 50%, #0F141F 0%, #0E1117 58%, #0B0C10 100%); }
body.ex-clearing .stage  { background: radial-gradient(ellipse at 50% 50%, #101613 0%, #0E1210 58%, #0B0C10 100%); }
body.ex-shift .stage     { background: radial-gradient(ellipse at 50% 50%, #141220 0%, #0F0F16 58%, #0B0C10 100%); }

/* Ambient artwork behind the canvas. Durations are deliberately staggered so no
   two elements pulse in sync: Grip 5s, Two 11s, Periphery 13s, Between 17s. */
.art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.art span {
  position: absolute;
  left: 50%;
  top: var(--art-y, 50%);
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
body.ex-periphery .art { --art-y: 40%; } /* the ring's lower arc collides with the instruction line at 50% */
body.ex-shift .art     { --art-y: 42%; }

.halo { filter: blur(10px); animation: lift 9s infinite alternate ease-in-out; }
body.ex-between .halo {
  width: 700px; height: 700px;
  filter: blur(14px);
  animation-duration: 17s;
  background: radial-gradient(circle, rgba(143,166,178,.07) 0%, rgba(143,166,178,.02) 46%, transparent 70%);
}
body.ex-two .halo {
  width: 820px; height: 520px;
  animation-duration: 11s;
  background: radial-gradient(ellipse, rgba(217,119,6,.1) 0%, rgba(217,119,6,.03) 46%, transparent 70%);
}
body.ex-contact .halo {
  width: 680px; height: 680px;
  animation-duration: 7s;
  background: radial-gradient(circle, rgba(59,130,246,.09) 0%, rgba(59,130,246,.03) 46%, transparent 70%);
}
body.ex-clearing .halo {
  width: 740px; height: 740px;
  filter: blur(13px);
  animation-duration: 15s;
  background: radial-gradient(circle, rgba(131,166,139,.08) 0%, rgba(131,166,139,.02) 46%, transparent 70%);
}
body.ex-shift .halo {
  width: 660px; height: 660px;
  filter: blur(12px);
  animation-duration: 19s;
  background: radial-gradient(circle, rgba(160,143,208,.09) 0%, rgba(160,143,208,.03) 46%, transparent 70%);
}
body.ex-periphery .halo {
  width: 640px; height: 640px;
  filter: blur(12px);
  animation-duration: 13s;
  background: radial-gradient(circle, rgba(6,182,212,.1) 0%, rgba(6,182,212,.03) 46%, transparent 70%);
}
body.ex-grip .halo {
  width: 620px; height: 620px;
  animation-duration: 5s;
  background: radial-gradient(circle, rgba(239,68,68,.14) 0%, rgba(239,68,68,.04) 44%, transparent 68%);
}

/* Rings — sized per exercise, drawn as bordered circles */
body.ex-periphery .r1 { width: 392px; height: 392px; border: 1px solid rgba(6,182,212,.14); }

body.ex-between .r1 { width: 460px; height: 460px; border: 1px solid rgba(143,166,178,.09); }
body.ex-contact .r1 { width: 430px; height: 430px; border: 1px solid rgba(59,130,246,.11); }
body.ex-clearing .r1 { width: 480px; height: 480px; border: 1px solid rgba(131,166,139,.09); }
body.ex-shift .r1    { width: 410px; height: 410px; border: 1px solid rgba(160,143,208,.1); }

body.ex-grip .r1 { width: 420px; height: 420px; border: 1px solid rgba(239,68,68,.1); }
body.ex-grip .r2 { width: 310px; height: 310px; border: 1px solid rgba(239,68,68,.16); }
body.ex-grip .r3 { width: 210px; height: 210px; border: 1px solid rgba(239,68,68,.26); }
body.ex-grip .r4 { width: 126px; height: 126px; border: 1px solid rgba(239,68,68,.42); }

#ex-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  /* Grip is a long press: no callout menu, no text selection on hold */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* While an overlay owns the screen the live chrome beneath it is inert —
   a Pause that does nothing and an instruction for a session not yet begun
   only add noise behind the scrim. */
.stage:has(.overlay.visible) .chrome-bottom {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.stage:has(.overlay.visible) .chrome-bottom a,
.stage:has(.overlay.visible) .chrome-bottom button { pointer-events: none; }

/* --- Paused: the stage recedes, the ambient art holds its breath --- */
#ex-canvas, .art { transition: opacity 0.6s ease; }
body.is-paused #ex-canvas,
body.is-paused .art { opacity: 0.4; }
body.is-paused .art span { animation-play-state: paused; }

/* --- Focus --- */
:where(a, button):focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 4px;
}
.btn:focus-visible, .pause:focus-visible {
  outline-offset: 2px;
  border-radius: 999px;
}

/* --- Chrome --- */
.chrome {
  position: absolute;
  inset: 0;
  padding: calc(30px + env(safe-area-inset-top, 0px))
           calc(40px + env(safe-area-inset-right, 0px))
           calc(36px + env(safe-area-inset-bottom, 0px))
           calc(40px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.chrome a, .chrome button { pointer-events: auto; }

.chrome-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.back {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--ink-42);
  text-decoration: none;
  transition: color 0.2s ease;
}
.back:hover { color: var(--night-ink); }
.back .glyph { font-size: 15px; line-height: 1; }

.chrome-id {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ex-name {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-34);
}
/* Round ticks — the only progress readout, and it carries no number */
.ticks { display: flex; }
.ticks i {
  height: 2px;
  border-radius: 1px;
  background: rgba(242, 241, 238, 0.16);
  font-style: normal;
}
body.ex-periphery .ticks { gap: 4px; }
body.ex-periphery .ticks i { width: 11px; }
body.ex-grip .ticks      { gap: 5px; }
body.ex-grip .ticks i    { width: 16px; }
body.ex-between .ticks   { gap: 4px; }
body.ex-between .ticks i { width: 13px; }
body.ex-two .ticks       { gap: 5px; }
body.ex-two .ticks i     { width: 22px; }
body.ex-contact .ticks   { gap: 5px; }
body.ex-contact .ticks i { width: 16px; }
body.ex-clearing .ticks  { gap: 5px; }
body.ex-clearing .ticks i { width: 18px; }
body.ex-shift .ticks     { gap: 5px; }
body.ex-shift .ticks i   { width: 20px; }
body.ex-periphery .ticks i.on { background: var(--periphery); }
body.ex-grip .ticks i.on      { background: var(--grip); }
body.ex-between .ticks i.on   { background: var(--between); }
body.ex-two .ticks i.on       { background: var(--two); }
body.ex-contact .ticks i.on   { background: var(--contact); }
body.ex-clearing .ticks i.on  { background: var(--clearing); }
body.ex-shift .ticks i.on     { background: var(--shift); }

.chrome-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Grip alone gets a phase kicker — the count *is* the exercise there */
#phase {
  margin-bottom: 22px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--grip);
  min-height: 13px;
}
#instruction {
  max-width: 620px;
  min-height: 1.2em; /* keeps the controls from jumping when the line empties */
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  color: rgba(242, 241, 238, 0.82);
  text-wrap: pretty;
  transition: opacity 0.22s ease;
}
#instruction.swap { opacity: 0; }
.controls {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-top: 26px;
}
.pause {
  height: 44px;
  padding: 0 26px;
  border: none;
  border-radius: 999px;
  background: rgba(242, 241, 238, 0.09);
  color: rgba(242, 241, 238, 0.78);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}
.pause:hover { background: rgba(242, 241, 238, 0.16); }
.end-early {
  font-size: 12px;
  color: rgba(242, 241, 238, 0.3);
  text-decoration: none;
  transition: color 0.2s ease;
}
.end-early:hover { color: rgba(242, 241, 238, 0.6); }

/* --- Overlays (start / complete) --- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 12, 16, 0.82);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.overlay.visible { opacity: 1; visibility: visible; }
.overlay-inner {
  max-width: 500px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.overlay-inner h2 {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 400;
  line-height: 1.05;
  text-wrap: pretty;
}
.overlay-inner p {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-62);
  text-wrap: pretty;
}
.overlay-inner .note { font-size: 12.5px; color: var(--ink-45); }
.btn-row { display: flex; align-items: center; gap: 22px; margin-top: 4px; }
.btn {
  padding: 16px 30px;
  border: none;
  border-radius: 999px;
  background: var(--amber);
  color: #14151A;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.btn:hover { background: var(--amber-hover); }
.btn.quiet {
  padding: 0;
  background: none;
  color: rgba(242, 241, 238, 0.66);
  font-size: 13.5px;
  font-weight: 400;
  border-bottom: 1px solid rgba(242, 241, 238, 0.24);
  border-radius: 0;
  padding-bottom: 3px;
}
.btn.quiet:hover { background: none; color: var(--night-ink); }
/* One quiet suggestion after a session — a door, not a curriculum */
.next-hint { margin-top: 6px; font-size: 12.5px; color: var(--ink-45); }
.next-hint a {
  color: var(--ink-62);
  text-decoration: none;
  border-bottom: 1px solid rgba(242, 241, 238, 0.2);
  transition: color 0.2s ease;
}
.next-hint a:hover { color: var(--night-ink); }

@media (max-width: 700px) {
  .chrome {
    padding: calc(22px + env(safe-area-inset-top, 0px))
             calc(22px + env(safe-area-inset-right, 0px))
             calc(28px + env(safe-area-inset-bottom, 0px))
             calc(22px + env(safe-area-inset-left, 0px));
  }
  #instruction { font-size: 26px; max-width: 90%; }
  .overlay-inner h2 { font-size: 32px; }
  .chrome-top { align-items: flex-start; }
  .chrome-id { flex-direction: column; align-items: flex-end; gap: 8px; }
  body.ex-periphery .halo, body.ex-grip .halo, body.ex-between .halo,
  body.ex-two .halo, body.ex-contact .halo, body.ex-clearing .halo,
  body.ex-shift .halo { width: 420px; height: 420px; }
  body.ex-shift .r1 { width: 280px; height: 280px; }
  body.ex-between .r1 { width: 300px; height: 300px; }
  body.ex-contact .r1 { width: 290px; height: 290px; }
  body.ex-clearing .r1 { width: 310px; height: 310px; }
  body.ex-periphery .r1 { width: 260px; height: 260px; }
  body.ex-grip .r1 { width: 290px; height: 290px; }
  body.ex-grip .r2 { width: 215px; height: 215px; }
  body.ex-grip .r3 { width: 150px; height: 150px; }
  body.ex-grip .r4 { width: 92px; height: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

/* Comfortable controls remain readable without competing with the field. */
.shift-intro { max-width: 620px; gap: 12px; }
.shift-intro h2 { font-size: 38px; }
.shift-intro > p { font-size: 17px; line-height: 1.55; }
.shift-intro > .note { font-size: 15px; }
.shift-guide { width: 100%; padding: 20px; border: 1px solid #555960; border-radius: 14px; background: #13151c; text-align: center; }
.shift-guide h3 { font-size: 22px; line-height: 1.3; font-weight: 500; margin-block: 8px 12px; color: #f2f1ee; }
.shift-guide .guide-position { font-size: 14px; color: #c3c6ca; }
.shift-guide .guide-explanation { font-size: 17px; line-height: 1.55; color: #e0e1e3; }
.guide-field { height: 85px; display: flex; align-items: center; justify-content: space-around; padding-inline: 20px; }
.guide-light { width: 15px; height: 15px; border-radius: 50%; background: #f2f1ee; position: relative; }
.guide-light.ringed::after { content: ''; position: absolute; inset: -14px; border: 3px solid #b2a1df; border-radius: 50%; animation: guide-ring-in .8s ease-out; }
.guide-centre { width: 5px; height: 5px; border-radius: 50%; background: #8d8997; }
@keyframes guide-ring-in { from { opacity: .15; } to { opacity: 1; } }
.guide-answers, .guide-navigation { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.shift-guide .pause { font-size: 17px; min-height: 48px; min-width: 86px; padding-inline: 18px; color: #f2f1ee; border: 1px solid #737780; }
.shift-guide .pause:disabled { opacity: .5; cursor: default; }
.shift-guide .guide-feedback { font-size: 15px; line-height: 1.5; color: #d5d8dc; min-height: 3em; margin-block: 14px; }
.shift-settings { width: 100%; text-align: left; color: #d5d8dc; }
.shift-settings summary { cursor: pointer; padding: 12px; font-size: 16px; }
.shift-help { margin: auto; width: min(640px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow-y: auto; padding: 24px; background: #101218; color: #f2f1ee; border: 1px solid #676b73; border-radius: 16px; text-align: center; }
.shift-help::backdrop { background: #06070bdd; }
.shift-help h2 { font-family: var(--serif); font-size: 32px; font-weight: 400; }
.shift-help > p { font-size: 16px; line-height: 1.5; margin-block: 14px; color: #d5d8dc; }
.shift-help > .btn { margin-top: 18px; }
.ex-shift .practice-actions .pause { font-size: 17px; min-height: 48px; }
.ex-shift #overlay-start { align-items: flex-start; }
.ex-shift .shift-intro { margin-block: auto; }
@media (max-width: 480px) { .shift-guide { padding: 16px 12px; } .shift-guide h3 { font-size: 21px; } .shift-help { padding: 16px; } }
[hidden] { display: none !important; }
.back, .end-early, .ex-name { color: #a8aaa9; }
.overlay-inner p, .overlay-inner .note, .next-hint { color: #b9bcbd; }
.overlay { overflow-y: auto; align-items: safe center; }
.overlay-inner { width: min(100%, 540px); padding-block: 16px; }
.practice-options { border: 1px solid #404449; border-radius: 12px; padding: 14px 18px; width: 100%; text-align: left; color: #ced0d1; font-size: 13px; }
.practice-options legend { padding-inline: 6px; }
.practice-options label { display: flex; align-items: center; gap: 12px; margin-block: 10px; }
.practice-options select { margin-left: auto; background: #202329; color: #f2f1ee; border: 1px solid #73787d; border-radius: 6px; padding: 8px; font: inherit; }
.practice-options input { accent-color: var(--amber); width: 18px; height: 18px; }
.visibility-sample { --sample-opacity: .5; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-block: 8px 14px; font-size: 12px; }
.visibility-sample i { display: block; flex: 0 0 12px; height: 12px; border-radius: 50%; background: #f2f1ee; opacity: var(--sample-opacity); }
.practice-actions { display: flex; gap: 12px; margin-top: 20px; pointer-events: auto; }
.practice-actions .pause { min-width: 90px; border: 1px solid #555a60; color: #f2f1ee; }
.controls { flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 16px; }
.pause { color: #d8d9da; }
.reflection .btn-row { gap: 8px; flex-wrap: wrap; justify-content: center; }
.reflection .pause { padding-inline: 16px; }
.reflection p { margin-top: 14px; }
.reflection [aria-pressed="true"] { outline: 2px solid var(--amber); outline-offset: 2px; }
:where(input,select):focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
@media (max-height: 600px) {
  .overlay { align-items: flex-start; }
  .chrome { padding-block: 16px; }
  #instruction { font-size: 22px; max-width: 620px; }
  .practice-actions { margin-top: 10px; }
}
@media (max-width: 480px) {
  .overlay { padding: 18px; }
  .overlay-inner { gap: 14px; }
  .practice-actions { gap: 8px; }
  .practice-actions .pause { min-width: 75px; padding-inline: 15px; }
  #instruction { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
