/* Meditation timer — an ensō that draws itself while you sit */

:root {
  --paper: hsl(41.8 89.2% 92.7%);  /* the site's cream */
  --sumi: #1f1b17;
  --dusk: #221e1a;
  --dusk-ink: #e9dcc0;
  --ash: #8c8478;
  --saffron: #d9a21b;              /* from the sun logo; focus only */
}

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

/* a quieter header on this page so the circle sits above the fold */
.site-header.compact { padding: 2.2vw 4vw 0; gap: .9rem; }
.site-header.compact .logo img { max-height: 110px; }
@media (max-width: 799px) { .site-header.compact { padding: 5vw 6vw 0; } .site-header.compact .logo img { max-height: 70px; } }

.sit {
  --ink-color: var(--sumi);
  background: var(--paper);
  color: var(--sumi);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3vh 6vw 10vh;
}

/* ---------- the ensō ---------- */
.enso-wrap {
  position: relative;
  width: min(400px, 74vw, 52vh);
  aspect-ratio: 1;
  margin: 0 auto;
}
.enso { width: 100%; height: 100%; overflow: visible; }
.enso .ink { fill: var(--ink-color); }
.enso .ghost { fill: var(--ink-color); opacity: 0; transition: opacity 2s; }
#reveal-stroke { transition: stroke-dashoffset .6s linear; }

.readout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.big {
  font-size: clamp(3.6rem, 13vw, 5.4rem);
  font-variation-settings: 'opsz' 96;
  font-variant-numeric: lining-nums;
  line-height: 1;
  min-height: 1em;
  transition: opacity 1.5s;
}
.small { font-style: italic; font-size: 1.05rem; margin-top: .35em; color: var(--ash); }

.step {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: none; color: inherit; cursor: pointer;
  font: 400 2.2rem/1 var(--serif);
  opacity: .7; transition: opacity .3s;
}
.step:hover { opacity: 1; }
.step:disabled { opacity: .15; cursor: default; }
.step-minus { left: -64px; }
.step-plus { right: -64px; }
@media (max-width: 560px) { .step-minus { left: -44px; } .step-plus { right: -44px; } .step { width: 44px; height: 44px; } }

/* ---------- words as controls ---------- */
.actions { display: flex; gap: 2.4rem; justify-content: center; margin: 2.2rem 0 2.6rem; min-height: 3rem; }
.word {
  font: italic 400 clamp(1.7rem, 5vw, 2.1rem) var(--serif);
  color: inherit; background: none; border: 0; cursor: pointer; padding: .1em .2em;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em;
}
.word.quiet { color: var(--ash); text-decoration: none; }
.word:hover { text-decoration-thickness: 2px; }

.options { display: flex; flex-direction: column; gap: .7rem; align-items: center; }
.opt {
  font: italic 400 1.05rem var(--serif);
  color: var(--ash); background: none; border: 0; cursor: pointer; padding: .2em .4em;
  text-decoration: underline dotted; text-underline-offset: .25em;
}
.opt:hover { color: var(--sumi); }

.hint { display: none; }

:is(.step, .word, .opt):focus-visible { outline: 2px solid var(--saffron); outline-offset: 4px; border-radius: 6px; }

/* ---------- sitting: the room goes dark ---------- */
body:is([data-timer="running"], [data-timer="paused"], [data-timer="done"]) { overflow: hidden; }
body:is([data-timer="running"], [data-timer="paused"], [data-timer="done"]) .sit {
  --ink-color: var(--dusk-ink);
  position: fixed; inset: 0; z-index: 100;
  justify-content: center;
  background: var(--dusk);
  color: var(--dusk-ink);
  padding: 6vh 6vw;
  animation: dusk 1.8s ease both;
}
@keyframes dusk { from { opacity: 0; } }

body:not([data-timer="idle"]) .step,
body:not([data-timer="idle"]) .options { display: none; }
body:not([data-timer="idle"]) .ghost { opacity: .09; }
body:not([data-timer="idle"]) .small { color: rgb(233 220 192 / .5); }
body[data-timer="running"] .big { opacity: .35; }
body[data-timer="running"] .actions { visibility: hidden; }
body[data-timer="running"] .sit { cursor: pointer; }
body:not([data-timer="idle"]) .word.quiet { color: rgb(233 220 192 / .55); }

body[data-timer="running"] .hint {
  display: block;
  position: absolute; bottom: 7vh; left: 0; right: 0;
  margin: 0; font-style: italic; font-size: 1rem; color: rgb(233 220 192 / .45);
  animation: hint 6s ease forwards;
}
@keyframes hint { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sit, .hint { animation: none !important; }
  #reveal-stroke, .ghost, .big { transition: none; }
}

/* − and + drawn as short ink strokes; Bodoni's own glyphs are hairlines */
.step::before, .step-plus::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 18px; height: 2px; border-radius: 1px; background: currentColor;
  transform: translate(-50%, -50%);
}
.step-plus::after { transform: translate(-50%, -50%) rotate(90deg); }
