/* The lower belly sigh: a photograph with the anatomy of one breath drawn over it. sigh.js builds everything inside [data-sigh-diagram].
   Every selector is rooted at the host or at .sigh, so nothing here reaches the rest of the page. */
[data-sigh-diagram] {
  --sigh-mineral: #304A50;
  --sigh-linen: #F1EBDD;
  --sigh-soft: #F7F3EA;
  --sigh-coral: #E87C50;
  --sigh-muted: #50666A;
  --sigh-light: #FFF7E8;       /* the drawing's line colour: warm white, like chalk on glass */
  --sigh-veil: #BFD3CB;        /* the lungs: a cool veil against the warm jumper */
  display: block;
  font-family: Bricolage, "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  color: var(--sigh-mineral);
}

/* layout (9 Nov): the picture runs the full width; the three captions sit in a row under it, or as a list below
   900 px of container. On the wide layout the heart rate stands on the empty wall at the top right of the photograph. */
.sigh { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "copy"; row-gap: clamp(18px, 2.2vw, 30px); margin: 0; }
.sigh .sigh-stage { grid-area: stage; position: relative; min-width: 0; aspect-ratio: 1536 / 700; overflow: hidden; border-radius: 4px; background: #DCCFBC; }   /* the photograph's own tone until it arrives */
.sigh .sigh-photo { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 500ms ease; }
.sigh .sigh-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: hidden; opacity: 0; transition: opacity 500ms ease 150ms; filter: drop-shadow(0 0 1.5px rgba(46, 34, 22, 0.55)); }   /* a soft dark edge keeps light lines readable on a light jumper */
.sigh.is-ready .sigh-photo, .sigh.is-ready .sigh-svg { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sigh .sigh-photo, .sigh .sigh-svg { transition: none; } }
.sigh .sigh-copy { grid-area: copy; min-width: 0; }

/* captions: all three on screen, the current one at full strength (sigh.js sets each opacity). Each is a button:
   a tap holds the drawing on that caption's moment. */
.sigh .sigh-captions { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: clamp(24px, 3.4vw, 52px); }
.sigh[data-layout="stacked"] .sigh-captions { grid-template-columns: minmax(0, 1fr); row-gap: 12px; max-width: 36em; }
.sigh .sigh-captions li { margin: 0; will-change: opacity; }
.sigh .sigh-cap {
  appearance: none; -webkit-appearance: none; display: block; width: 100%; margin: 0; padding: 0; border: 0; border-radius: 4px; background: none;
  font: inherit; font-size: clamp(20px, 1.55vw, 21px); line-height: 1.42; letter-spacing: -0.008em; text-align: left; text-wrap: pretty;
  color: var(--sigh-mineral); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.sigh[data-drawing="compact"] .sigh-cap { font-size: 19px; line-height: 1.42; }
.sigh .sigh-cap:disabled { color: var(--sigh-mineral); cursor: text; }
.sigh .sigh-cap:focus-visible { outline: 2px solid var(--sigh-mineral); outline-offset: 5px; }
@media (hover: hover) and (pointer: fine) { .sigh:not(.is-still) .sigh-captions li:hover { opacity: 1 !important; } }

/* the round button: pause wherever the breath is, or carry on from a held caption */
.sigh .sigh-toggle {
  grid-area: stage; place-self: end end; position: relative; z-index: 1; margin: 0 14px 14px 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: color-mix(in srgb, var(--sigh-soft) 82%, transparent); color: var(--sigh-mineral);   /* a light disc: it sits on the photograph */
  transition: background-color 200ms ease, transform 500ms cubic-bezier(.3, 1.4, .5, 1);
}
.sigh .sigh-toggle:active { transform: scale(0.9); transition-duration: 200ms, 90ms; }
.sigh .sigh-toggle:focus-visible { outline: 2px solid var(--sigh-mineral); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) { .sigh .sigh-toggle:hover { background: var(--sigh-soft); } }
.sigh .sigh-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.sigh .sigh-toggle .sigh-i-play, .sigh .sigh-toggle[aria-pressed="true"] .sigh-i-pause { display: none; }
.sigh .sigh-toggle[aria-pressed="true"] .sigh-i-play { display: block; }
.sigh[data-layout="stacked"] .sigh-toggle { grid-area: copy; place-self: start end; margin: 4px 0 0; background: color-mix(in srgb, var(--sigh-mineral) 9%, transparent); }   /* beside the heart rate, on the page */
.sigh .sigh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* heart rate: the one big figure; one calm colour, so the falling number carries the message */
.sigh .sigh-rate { margin: 0 0 14px; display: flex; flex-direction: column; gap: 2px; }
.sigh[data-layout="side"] .sigh-rate { position: absolute; top: clamp(18px, 2.4vw, 34px); right: clamp(20px, 2.8vw, 40px); margin: 0; }
.sigh .sigh-rate-row { display: flex; align-items: baseline; gap: 6px; }
.sigh .sigh-rate-num {
  display: inline-block; min-width: 2ch;
  font-size: clamp(56px, 5.6vw, 84px); line-height: 1; font-weight: 500; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; font-variation-settings: "opsz" 72;
  color: var(--sigh-mineral);
  will-change: opacity, transform;
}
.sigh .sigh-rate-unit { font-size: 18px; color: var(--sigh-muted); }
.sigh[data-layout="side"]:not(.is-still):not(.no-photo) :is(.sigh-rate-num, .sigh-rate-unit) { color: #1E3338; }   /* on the photograph's wall the page's tones are too faint: a darker mineral reaches 4.5:1 */
.sigh[data-drawing="compact"] .sigh-rate-num { font-size: 52px; }


/* the drawing: light lines and soft fills over the photograph. Values that change over the breath (opacity,
   fill-opacity on the stem, lobe and heart, stroke-opacity on the fibres) are set by sigh.js, so they stay out of here. */
.sigh .sigh-brain { fill: var(--sigh-light); fill-opacity: 0.1; stroke: var(--sigh-light); stroke-opacity: 0.85; stroke-width: 1.3; }
.sigh .sigh-fold { stroke: var(--sigh-light); stroke-opacity: 0.6; stroke-width: 1; }
.sigh .sigh-stem { fill: var(--sigh-light); stroke: var(--sigh-light); stroke-opacity: 0.9; stroke-width: 1; }
.sigh .sigh-ring { fill: none; stroke: var(--sigh-light); stroke-width: 1.2; }
.sigh .sigh-lung { fill: var(--sigh-veil); fill-opacity: 0.34; stroke: var(--sigh-light); stroke-opacity: 0.9; stroke-width: 1.4; }
.sigh .sigh-lobe { fill: var(--sigh-light); }
.sigh .sigh-fissure { stroke: var(--sigh-light); stroke-opacity: 0.55; stroke-width: 1; }
.sigh .sigh-heart { fill: var(--sigh-coral); stroke: var(--sigh-light); stroke-opacity: 0.95; stroke-width: 1.3; stroke-linejoin: round; }
.sigh .sigh-airway { stroke: var(--sigh-light); stroke-opacity: 0.6; stroke-width: 1.1; }
.sigh .sigh-diaphragm { stroke: var(--sigh-light); stroke-opacity: 0.95; stroke-width: 2.6; }
.sigh .sigh-nerve { stroke: var(--sigh-light); stroke-opacity: 0.85; stroke-width: 1.6; }
.sigh .sigh-fiber { stroke: var(--sigh-light); stroke-width: 1; }
.sigh .sigh-fiber-lit { stroke: var(--sigh-coral); stroke-width: 1.4; }
.sigh .sigh-route { stroke: var(--sigh-coral); stroke-width: 2.2; }
.sigh .sigh-route-glow { stroke: var(--sigh-coral); stroke-opacity: 0.28; stroke-width: 7; }
.sigh .sigh-receptor { fill: var(--sigh-light); fill-opacity: 0.85; }
.sigh .sigh-receptor-ring { fill: none; stroke: var(--sigh-coral); stroke-width: 1.2; }
.sigh .sigh-signal { fill: var(--sigh-coral); }
.sigh .sigh-s-coral { stop-color: var(--sigh-coral); }
.sigh .sigh-s-light { stop-color: var(--sigh-light); }
/* a narrow picture: finer lines, and the photograph runs to the screen's edges */
.sigh[data-drawing="compact"] .sigh-stage { margin-inline: calc(-1 * var(--gutter, 20px)); border-radius: 0; }
.sigh[data-drawing="compact"] .sigh-diaphragm { stroke-width: 1.9; }
.sigh[data-drawing="compact"] :is(.sigh-lung, .sigh-nerve, .sigh-brain, .sigh-heart) { stroke-width: 1.1; }
.sigh[data-drawing="compact"] :is(.sigh-fold, .sigh-fissure, .sigh-airway, .sigh-fiber) { stroke-width: 0.8; }
.sigh[data-drawing="compact"] .sigh-route { stroke-width: 1.7; }
.sigh[data-drawing="compact"] .sigh-route-glow { stroke-width: 5; }

/* reduced motion: a still frame, all three captions as a plain list, no controls */
.sigh.is-still .sigh-captions { display: block; max-width: 36em; }
.sigh.is-still .sigh-captions li { opacity: 1; }
.sigh.is-still .sigh-captions li + li { margin-top: 0.7em; }
.sigh.is-still .sigh-cap { cursor: text; pointer-events: none; }
.sigh.is-still .sigh-toggle, .sigh:not(.is-ready) .sigh-toggle { display: none; }
/* the photograph did not arrive: no picture, the heart rate and captions stay */
.sigh.no-photo .sigh-stage { display: none; }
.sigh.no-photo[data-layout="side"] .sigh-rate { position: static; margin: 0 0 14px; }
.sigh.is-still[data-layout="side"] .sigh-rate { position: static; margin: 0 0 14px; }   /* "75 → 59" is too wide for the wall */
