/* ══════════════════════════════════════════════════════════════════
   TANAFFUS · تنفس · guided breathing (Version 2)
   Built on site.css + chill.css. Everything here is prefixed tf-.

   · Every pattern is drawn as the shape of its breath: a line that
     rises on the inhale, rests on a hold and falls on the exhale.
     The same drawing is the progress bar during a session.
   · Phases have one colour each (in, hold, out); <body data-phase>
     sets --ph and everything that follows the breath reads it.
   · In a session the page clears to one flat disc, a thin ring and a
     big, gentle word. The page takes on a faint wash of the phase's
     colour, slowly. No glow, no glass.
   ══════════════════════════════════════════════════════════════════ */

.tf { --ph: var(--ch-in); transition: background-color 2.4s var(--ease); }
.tf[data-phase="hold"] { --ph: var(--ch-hold); }
.tf[data-phase="exhale"] { --ph: var(--ch-out); }
.tf main { display: block; }
.tf [hidden] { display: none !important; }
.tf.is-session { background-color: color-mix(in srgb, var(--ph) 5%, var(--bg)); }

/* phase colour helpers */
.tf-k-inhale { --k: var(--ch-in); }
.tf-k-hold   { --k: var(--ch-hold); }
.tf-k-exhale { --k: var(--ch-out); }

/* ── The breath graph ────────────────────────────────────────────── */
.tf-graph { position: relative; display: grid; gap: 12px; }
.tf-graph svg { display: block; width: 100%; height: auto; overflow: visible; }
.tf-base { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 5; fill: none; vector-effect: non-scaling-stroke; }
.tf-area { fill: var(--k); stroke: none; transition: fill-opacity .6s var(--ease), opacity 1s var(--ease); }
.tf-area.tf-k-inhale { fill: url(#tf-fade-inhale); }
.tf-area.tf-k-hold { fill: url(#tf-fade-hold); }
.tf-area.tf-k-exhale { fill: url(#tf-fade-exhale); }
.tf-stop { stop-opacity: 0.2; }
.tf-stop--in { stop-color: var(--ch-in); }
.tf-stop--hold { stop-color: var(--ch-hold); stop-opacity: 0.14; }
.tf-stop--out { stop-color: var(--ch-out); }
.tf-stop--end { stop-opacity: 0; }
.tf-seg { fill: none; stroke: var(--k); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: stroke-opacity .6s var(--ease), stroke-width .6s var(--ease); }
.tf-plot { position: relative; }
.tf-gdot {
    position: absolute; left: 0; top: 100%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
    background: var(--fg); box-shadow: 0 0 0 3px var(--bg-2);
    pointer-events: none;
}
.tf-active .tf-gdot { box-shadow: 0 0 0 3px var(--bg); background: var(--ph); }
.tf-card .tf-graph svg { height: clamp(96px, 11vw, 128px); }
.tf-graph.is-preview .tf-labels span.is-now { color: var(--fg-2); }
.tf-labels { display: flex; gap: 6px; }
.tf-labels span {
    min-width: 0; padding-top: 9px; border-top: 2px solid var(--k);
    font-size: 13px; line-height: 1.3; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: color .5s var(--ease), opacity .5s var(--ease);
}
.tf-labels span b { display: block; font-weight: 600; color: var(--fg); font-size: 15px; font-variant-numeric: tabular-nums; }
/* in a running session: the current phase is lit, the rest recede */
.tf-graph.is-running .tf-seg { stroke-opacity: 0.3; }
.tf-graph.is-running .tf-seg.is-now { stroke-opacity: 1; stroke-width: 3.5; }
.tf-graph.is-running .tf-area { fill-opacity: 0.35; }
.tf-graph.is-running .tf-area.is-now { fill-opacity: 1; }
.tf-graph.is-running .tf-labels span { opacity: 0.5; }
.tf-graph.is-running .tf-labels span.is-now { opacity: 1; color: var(--fg-2); }

/* ── Hero: the name, and the session card beside it ──────────────── */
.tf-hero {
    display: grid; gap: clamp(36px, 5vw, 72px); align-items: center;
    padding: clamp(40px, 6vw, 88px) 0 clamp(24px, 3vw, 40px);
}
@media (min-width: 960px) { .tf-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.tf-hero-copy { display: grid; gap: 20px; justify-items: start; }
.tf-hero-copy .eyebrow { margin: 0 0 -6px; color: var(--ch-sage-text); }
.tf-title {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.14em 0.24em;
    font-size: clamp(56px, 6.4vw, 92px); line-height: 1.04; letter-spacing: -0.036em; font-weight: 600;
}
.tf-lead { max-width: 30ch; font-size: clamp(19px, 2vw, 24px); line-height: 1.38; letter-spacing: -0.014em; color: var(--fg-2); text-wrap: pretty; }
.tf-lead em { font-style: normal; font-weight: 600; color: var(--fg); }

.tf-card {
    position: relative; display: grid; gap: 20px;
    padding: clamp(24px, 3vw, 36px); border-radius: var(--radius-lg);
    background: var(--bg-2);
    container: card / inline-size;
}
.tf-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tf-card-tag { font-size: 15px; font-weight: 600; color: var(--ch-sage-text); }
.tf-card-len { font-size: 14px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.tf-card-name { margin-top: -10px; font-size: clamp(34px, 3.6vw, 48px); line-height: 1.06; letter-spacing: -0.028em; font-weight: 600; text-wrap: balance; }
.tf-card-best { color: var(--fg-2); font-size: 17px; line-height: 1.47; max-width: 48ch; text-wrap: pretty; margin-top: -8px; }
.tf-card .tf-graph { padding: 10px 0 2px; }

.tf-why { border-top: 1px solid var(--line); padding-top: 16px; }
.tf-why summary {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
    font-size: 15px; color: var(--accent);
}
.tf-why summary::-webkit-details-marker { display: none; }
.tf-why summary::after { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg) translateY(-2px); transition: transform .4s var(--ease-out); }
.tf-why[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.tf-why summary:hover { text-decoration: underline; text-underline-offset: 0.18em; }
.tf-why summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.tf-why p { margin-top: 12px; color: var(--fg-2); font-size: 15px; line-height: 1.6; max-width: 60ch; }

.tf-custom { display: grid; gap: 4px; padding: 14px 18px; border-radius: 18px; background: var(--bg-3); }
.tf-slider { display: grid; grid-template-columns: 6.4em minmax(0, 1fr) 3.4ch; align-items: center; gap: 14px; }
.tf-slider label { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; color: var(--fg-2); white-space: nowrap; }
.tf-slider label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--k); flex-shrink: 0; }
.tf-slider .ch-range { --tint: var(--k); --track: var(--line-2); }
.tf-slider output { font-size: 14px; font-weight: 600; color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }

.tf-card-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 20px; align-items: end; padding-top: 20px; border-top: 1px solid var(--line); }
.tf-rounds { display: grid; gap: 10px; justify-items: start; }
.tf-rounds-head { display: flex; align-items: baseline; gap: 12px; font-size: 14px; font-weight: 500; color: var(--fg-2); }
.tf-rounds-head output { color: var(--fg-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.tf-rounds .ch-seg button { min-width: 50px; font-size: 15px; }
.tf-begin { gap: 12px; }
.tf-begin .ch-i { width: 15px; height: 15px; }
.tf-prefs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin: -8px 0 -10px -12px; }
.tf-prefs .tf-hint { margin-left: auto; font-size: 13px; color: var(--fg-3); display: inline-flex; align-items: center; gap: 8px; }
@media (hover: none) { .tf-prefs .tf-hint { display: none; } }
.tf-toggle { color: var(--fg-2); font-size: 15px; min-height: 40px; }
.tf-toggle .ch-i { width: 18px; height: 18px; }
.tf-toggle .i-off { display: none; }
.tf-toggle[aria-pressed="false"] .i-on { display: none; }
.tf-toggle[aria-pressed="false"] .i-off { display: block; }
.tf-toggle[aria-pressed="false"] { color: var(--fg-3); }

@container card (max-width: 460px) {
    .tf-card-foot { grid-template-columns: minmax(0, 1fr); }
    .tf-begin { width: 100%; }
}

/* ── Pattern cards ───────────────────────────────────────────────── */
.tf-patterns-sec { padding-bottom: clamp(88px, 11vw, 150px); }
.tf-patterns-sec .ch-sec-idx { color: var(--fg-3); }
.tf-patterns { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tf-patterns li.is-wide { grid-column: 1 / -1; }
.tf-pat {
    width: 100%; height: 100%; display: grid; gap: 16px; align-content: start;
    padding: 24px 24px 26px; border: 0; border-radius: 24px; text-align: left; cursor: pointer;
    background: var(--bg-2); color: var(--fg);
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
    transition: background-color .5s var(--ease), transform .6s var(--ease-out), color .5s var(--ease);
}
.tf-pat:hover { background: var(--bg-3); transform: scale(1.012); }
.tf-pat:active { transform: scale(0.99); }
.tf-pat:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tf-pat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.tf-pat-tag { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--fg-2); }
.tf-pat-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px currentColor; }
.tf-pat .tf-graph svg { height: 60px; }
.tf-pat .tf-seg { stroke-width: 2; }
.tf-pat-name { font-size: clamp(24px, 2.2vw, 28px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 600; }
.tf-pat-best { font-size: 15px; line-height: 1.45; color: var(--fg-3); margin-top: -8px; text-wrap: pretty; }
.tf-pat[aria-pressed="true"] { background: var(--ch-sage); color: var(--ch-ink); transform: none; }
.tf-pat[aria-pressed="true"] .tf-pat-top, .tf-pat[aria-pressed="true"] .tf-pat-tag, .tf-pat[aria-pressed="true"] .tf-pat-best { color: color-mix(in srgb, var(--ch-ink) 70%, transparent); }
.tf-pat[aria-pressed="true"] .tf-pat-tag::before { background: currentColor; }
.tf-pat[aria-pressed="true"] .tf-seg { stroke: var(--ch-ink); }
.tf-pat[aria-pressed="true"] .tf-area { fill: var(--ch-ink); fill-opacity: 0.07; }
.tf-pat[aria-pressed="true"] .tf-base { stroke: color-mix(in srgb, var(--ch-ink) 30%, transparent); }
.is-wide .tf-pat { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 12px 32px; }
.is-wide .tf-pat > .tf-graph { grid-column: 2; grid-row: 1 / span 3; }
/* each breath draws its own shape as the patterns arrive */
/* (the breath is uncovered left to right, in the order it is breathed) */
.js .tf-patterns li .tf-plot { clip-path: inset(-12px 100% -12px -12px); }
.js .tf-patterns li.is-in .tf-plot { clip-path: inset(-12px -12px -12px -12px); transition: clip-path 1.4s cubic-bezier(0.45, 0, 0.55, 1) calc(var(--d, 0s) + .3s); }
:root[data-palette="snowy-owl"] .tf-pat:not([aria-pressed="true"]) { background: #EDEDF0; }
:root[data-palette="snowy-owl"] .tf-pat:not([aria-pressed="true"]):hover { background: #E4E4E9; }

/* ── Begin bar (when the card is off screen) ─────────────────────── */
.tf-go {
    position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 900;
    width: min(560px, calc(100vw - 24px)); min-height: 64px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
    padding: 8px 8px 8px 24px; border-radius: 980px;
    box-shadow: 0 24px 48px -20px rgba(0, 0, 0, 0.55);
    opacity: 0; transform: translate(-50%, 130%); pointer-events: none;
    transition: opacity .5s var(--ease), transform .7s var(--ease-out);
}
.tf-go.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.tf-go p { min-width: 0; display: grid; gap: 3px; }
.tf-go b { font-weight: 600; font-size: 17px; letter-spacing: -0.014em; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-go span { font-size: 13px; color: var(--p-fg-2); font-variant-numeric: tabular-nums; }
.tf-go .ch-btn { gap: 10px; }
.tf-go .ch-btn .ch-i { width: 14px; height: 14px; }
body.tf-go-open { --dock-space: 80px; }
body.tf-go-open .ft { padding-bottom: 96px; }
body.tf-go-open .tf-patterns-sec { padding-bottom: calc(clamp(88px, 11vw, 150px) + 64px); }

/* ── Session ─────────────────────────────────────────────────────── */
.tf-active {
    min-height: calc(100svh - var(--nav-h));
    display: grid; align-content: center; justify-items: center; gap: clamp(12px, 2.4vh, 26px);
    padding: clamp(12px, 2vh, 24px) 0 clamp(20px, 3.4vh, 40px);
}
.tf.is-session .gn { opacity: 0.4; transition: opacity 1.2s var(--ease); }
.tf.is-session .gn:hover, .tf.is-session .gn:focus-within { opacity: 1; }
.tf-active-top { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font-size: 15px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.tf-active-top b { font-weight: 600; color: var(--fg); }
.tf-active-top > span { display: inline-flex; align-items: center; gap: 6px; }
.tf-active-top > span + span::before { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--fg-3); margin-right: 14px; }

.tf-orb-wrap {
    position: relative; display: grid; place-items: center;
    width: min(400px, 80vw, 46svh); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: var(--fg); cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tf-orb-wrap:focus-visible { outline: 2px solid var(--fg); outline-offset: 10px; }
.tf-orb-wrap > * { grid-area: 1 / 1; }
.tf-ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.tf-ring-track { fill: none; stroke: var(--line-2); stroke-width: 1; }
.tf-ring-prog { fill: none; stroke: var(--ph); stroke-width: 2.5; stroke-linecap: round; transition: stroke-dashoffset var(--ring-t, 0s) linear, stroke 1.2s var(--ease); }
.tf-orb {
    display: block; width: 90%; aspect-ratio: 1; border-radius: 50%;
    transform: scale(0.55);
    background: color-mix(in srgb, var(--ph) 20%, var(--bg));
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ph) 55%, transparent);
    transition-property: transform, background-color, box-shadow, scale;
    transition-timing-function: cubic-bezier(0.37, 0, 0.3, 1), ease, ease, ease;
    transition-duration: var(--orb-t, 4s), 1.6s, 1.6s, .6s;
    will-change: transform;
}
.tf-orb.is-ready { animation: tf-ready 2.6s ease-in-out infinite; }
@keyframes tf-ready { 50% { scale: 1.08; } }
.tf-orb-text { position: relative; z-index: 2; display: grid; justify-items: center; gap: 6px; max-width: calc(49.5% - 20px); pointer-events: none; text-align: center; }
.tf-phase { font-size: clamp(21px, 2.2vw, 31px); line-height: 1.06; letter-spacing: -0.028em; font-weight: 600; color: var(--fg); text-wrap: balance; }
.tf-count { font-size: clamp(19px, 2vw, 24px); font-weight: 500; line-height: 1; color: var(--ph); min-height: 1em; font-variant-numeric: tabular-nums; transition: color 1.2s var(--ease); }

.tf-run { width: min(640px, 100%); }
.tf-active .tf-graph svg { height: 64px; }
.tf-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tf-quote { max-width: 44ch; min-height: calc(3 * 1.42 * clamp(17px, 1.7vw, 21px) + 30px); margin: 0; text-align: center; transition: opacity 1s var(--ease), transform 1s var(--ease-out); }
.tf-quote.is-hidden { opacity: 0; transform: translateY(6px); }
.tf-quote blockquote { margin: 0; font-size: clamp(17px, 1.7vw, 21px); line-height: 1.42; letter-spacing: -0.012em; color: var(--fg-2); text-wrap: balance; }
.tf-quote figcaption { margin-top: 10px; font-size: 13px; color: var(--fg-3); }

/* ── Done ────────────────────────────────────────────────────────── */
.tf-done {
    min-height: calc(100svh - var(--nav-h));
    display: grid; align-content: center; justify-items: center; gap: 22px; text-align: center;
    padding: clamp(40px, 7vh, 88px) 0;
}
.tf-done-mark { width: 84px; height: 84px; margin-bottom: 4px; }
.tf-done-mark circle { fill: none; stroke: var(--ch-sage-text); stroke-width: 2; }
.tf-done-mark circle + circle { fill: var(--ch-sage-text); stroke: none; }
.tf-done .eyebrow { margin: 0 0 -10px; color: var(--ch-sage-text); }
.tf-done-title:focus { outline: none; }
.tf-done-title { font-size: clamp(56px, 8vw, 96px); line-height: 1; letter-spacing: -0.036em; font-weight: 600; }
.tf-done-sub { color: var(--fg-2); font-size: clamp(19px, 2vw, 24px); line-height: 1.38; max-width: 34ch; }
.tf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(560px, 100%); margin: 12px 0 0; }
.tf-stats div { display: grid; gap: 8px; padding: 8px; }
.tf-stats div + div { border-left: 1px solid var(--line); }
.tf-stats dt { order: 2; font-size: 14px; color: var(--fg-3); }
.tf-stats dd { order: 1; margin: 0; font-size: clamp(40px, 5vw, 56px); line-height: 1; letter-spacing: -0.03em; font-weight: 600; font-variant-numeric: tabular-nums; }
.tf-done-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 10px; }
.tf-done-link { display: inline-flex; align-items: center; gap: 4px; font-size: 17px; color: var(--accent); padding: 8px 4px; }
.tf-done-link .ch-i { width: 16px; height: 16px; transition: transform .3s var(--ease); }
.tf-done-link:hover .ch-i { transform: translateX(3px); }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .tf-patterns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .tf-card { border-radius: 24px; }
    .tf-patterns { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .tf-pat { grid-template-columns: minmax(0, 1fr) 42%; align-items: center; gap: 6px 16px; padding: 18px; border-radius: 20px; }
    .tf-pat > .tf-graph { grid-column: 2; grid-row: 1 / span 3; }
    .tf-pat .tf-graph svg { height: 48px; }
    .tf-pat-name { font-size: 22px; }
    .tf-pat-best { display: none; }
    .is-wide .tf-pat { grid-template-columns: minmax(0, 1fr) 42%; }
    .tf-quote { min-height: calc(4 * 1.42 * clamp(17px, 1.7vw, 21px) + 30px); }
    .tf-labels span { font-size: 12px; white-space: normal; overflow: visible; text-overflow: clip; min-width: min-content; }
    .tf-labels span b { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    /* The orb and its ring are the guide, not decoration: keep their slow, steady motion
       (site.css shortens every transition when motion is reduced). */
    .tf .tf-orb { transition-duration: var(--orb-t, 4s), 0.01ms, 0.01ms, 0.01ms !important; }
    .tf .tf-ring-prog { transition-duration: var(--ring-t, 0s), 0.01ms !important; }
    .tf-orb.is-ready { animation: none; }
    .tf-pat:hover { transform: none; }
    .js .tf-patterns li .tf-plot { clip-path: none; }
    .tf.is-session .gn { transition: none; }
}
