/* Tide Mechanics page (src/pages/tide-mechanics.html). Its own type and chart palette, scoped
   to .tm so the site header and footer keep the site's tokens. Night colours follow
   prefers-color-scheme, as the rest of the site does; assets/tide-mechanics.js redraws the
   canvases when the OS scheme changes. */
.tm{
  --bg:#f3f5f2; --paper:#fbfcfa; --ink:#13263a; --ink-2:#4a5d6e; --muted:#7f909e;
  --rule:#c6d0d6; --grid:#e1e7ea; --shoal:#dce9f1; --land:#ece4cc;
  --accent:#a8136f; --accent-soft:#f6dcea;
  --c-m2:#1c4f8a; --c-s2:#a8136f; --c-n2:#0f7a73; --c-k1:#a8620a; --c-o1:#4d7a1d; --c-m4:#7a5c3a;
  --c-sum:#13263a; --c-fit:#a8136f; --c-obs:#7f909e;
  --ok:#0f7a54; --warn:#a8620a; --bad:#b3261e;
  --focus:#a8136f;
  --f-display:"Libre Bodoni", Georgia, serif;
  --f-body:"IBM Plex Sans", system-ui, sans-serif;
  --f-mono:"IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  .tm{
    --bg:#0b1622; --paper:#0f1d2b; --ink:#dce6ee; --ink-2:#a3b5c3; --muted:#6f8394;
    --rule:#2b3e50; --grid:#1a2c3c; --shoal:#14293b; --land:#2a2a1f;
    --accent:#e67ac0; --accent-soft:#3a1c30;
    --c-m2:#7fb2ec; --c-s2:#e67ac0; --c-n2:#52c7bb; --c-k1:#e5a63e; --c-o1:#9ccc5c; --c-m4:#c9a27a;
    --c-sum:#e8eef3; --c-fit:#e67ac0; --c-obs:#6f8394;
    --ok:#4fc58f; --warn:#e5a63e; --bad:#f07a70; --focus:#e67ac0;
    color-scheme: dark;
  }
}
.tm{background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:17px;line-height:1.55;overflow-x:clip}
.tm *{box-sizing:border-box}
.tm .tm-wrap{max-width:980px;margin:0 auto;padding-inline:clamp(16px,4vw,40px);padding-block:40px 80px}
.tm h1,.tm h2,.tm h3{font-family:var(--f-display);font-weight:700;text-wrap:balance;line-height:1.15;margin:0;letter-spacing:normal}
.tm h1{font-size:clamp(2.1rem,5.5vw,3.4rem);letter-spacing:-.01em}
.tm h2{font-size:clamp(1.5rem,3.6vw,2.1rem);display:flex;gap:.6em;align-items:baseline}
.tm h2 .n{font-family:var(--f-mono);font-weight:500;font-size:.55em;color:var(--accent);border:1.5px solid var(--accent);border-radius:50%;width:2.1em;height:2.1em;display:inline-grid;place-items:center;flex:none;transform:translateY(-.15em)}
.tm h3{font-size:1.15rem}
.tm p{margin:.6em 0;line-height:1.55}
.tm .lede{font-size:1.1rem;color:var(--ink-2)}
.tm .top{border-bottom:2px solid var(--ink);padding-bottom:22px;margin-bottom:12px;position:relative}
.tm .top .kicker{font-family:var(--f-mono);font-size:.8rem;letter-spacing:.12em;text-transform:uppercase;color:var(--accent)}
.tm .toc{display:flex;flex-wrap:wrap;gap:6px 14px;font-family:var(--f-mono);font-size:.82rem;margin-top:14px;padding:0;list-style:none}
.tm .toc a{color:var(--ink-2);text-decoration:none;border-bottom:1px dotted var(--rule)}
.tm .toc a:hover{color:var(--accent)}
.tm section{padding-top:44px;margin-top:28px;border-top:1px solid var(--rule)}
.tm section:first-of-type{border-top:0}
.tm .fig{margin:18px 0 6px;min-width:0}
.tm .fig canvas{display:block;width:100%;background:var(--paper);border:1px solid var(--rule);border-radius:3px}
/* Reserve each figure's drawn height before assets/tide-mechanics.js runs, so the page does not
   shift after load and a link to #s4 or #s6 lands on its heading. These match the heights the
   draw functions pass to prep(); w is the width of the .fig, hence the container query. */
.tm .fig{container-type:inline-size}
#s1-lanes{height:364px}
#s1-month{height:clamp(190px,30cqw,260px)}
#s2-spec{height:442px}
#s3-wave{height:300px}
#s3-nodal{height:220px}
#s4-clock,#s4-mer{height:min(154px,calc(20cqw + 46px))}
#s5-plot{height:320px}
#s6-time{height:238px}
#s7-h{height:150px}
#s7-sub{height:190px}
#s7-cur{height:290px}
#s7-surge{height:240px}
@container (width < 560px){
  #s2-spec{height:598px}
  #s3-wave{height:270px}
  #s5-plot{height:300px}
}
.tm .cap{font-size:.92rem;color:var(--ink-2);margin:.5em 0}
.tm .cap b{color:var(--ink)}
.tm .mono{font-family:var(--f-mono)}
.tm .controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));gap:8px 18px;margin:14px 0;padding:12px 14px;background:var(--shoal);border-radius:3px}
.tm .ctl{display:grid;grid-template-columns:auto 1fr auto;gap:8px;align-items:center;font-size:.9rem;min-width:0}
.tm .ctl label{white-space:nowrap}
.tm .ctl output{font-family:var(--f-mono);font-size:.82rem;min-width:5.2em;text-align:right}
.tm .ctl.chk{grid-template-columns:auto auto 1fr auto}
.tm .sw{display:inline-block;width:14px;height:4px;border-radius:2px;vertical-align:middle}
.tm input[type=range]{width:100%;min-width:0;accent-color:var(--accent)}
.tm input[type=checkbox]{accent-color:var(--accent);width:16px;height:16px}
.tm select{font:inherit;font-size:.9rem;background:var(--paper);color:var(--ink);border:1px solid var(--rule);border-radius:3px;padding:3px 6px}
.tm button{font:inherit;font-size:.86rem;background:var(--paper);color:var(--ink);border:1px solid var(--rule);border-radius:3px;padding:5px 10px;cursor:pointer}
.tm button:hover{border-color:var(--accent)}
.tm button[aria-pressed="true"]{background:var(--accent);color:var(--paper);border-color:var(--accent)}
.tm :focus-visible{outline:2.5px solid var(--focus);outline-offset:2px}
.tm .btnrow{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:10px 0}
.tm .btnrow .lbl{font-size:.85rem;color:var(--ink-2)}
.tm .tbl{overflow-x:auto;margin:12px 0;max-width:100%}
.tm table{border-collapse:collapse;font-size:.86rem;width:100%}
.tm th,.tm td{padding:5px 8px;text-align:right;vertical-align:baseline;border-bottom:1px solid var(--grid);white-space:nowrap}
.tm th{font-family:var(--f-body);font-weight:600;color:var(--ink-2);border-bottom:1.5px solid var(--ink);font-size:.78rem;text-transform:uppercase;letter-spacing:.04em}
.tm th .sym{text-transform:none;letter-spacing:0}
.tm td:first-child,.tm th:first-child{text-align:left}
.tm td{font-family:var(--f-mono)}
.tm tr.yes td{color:var(--ink)} .tm tr.no td{color:var(--muted)}
.tm .pill{display:inline-block;font-family:var(--f-body);font-size:.72rem;font-weight:600;padding:1px 7px;border-radius:9px;letter-spacing:.02em}
.tm .pill.ok{background:var(--ok);color:var(--paper)} .tm .pill.no{border:1px solid var(--muted);color:var(--muted)}
.tm .pill.pub{background:var(--c-m2);color:var(--paper)} .tm .pill.sdk{background:var(--accent);color:var(--paper)} .tm .pill.fix{border:1px solid var(--ink-2);color:var(--ink-2)}
/* formula */
.tm .formula{font-family:var(--f-display);font-size:clamp(1.15rem,3.6vw,1.9rem);padding:16px 10px;text-align:center;background:var(--paper);border:1px solid var(--rule);border-radius:3px;line-height:1.9}
.tm .formula button.t{font:inherit;background:none;border:0;border-bottom:3px solid transparent;padding:0 .08em;border-radius:0;color:var(--ink);cursor:pointer}
.tm .formula button.t[data-owner="pub"]{border-bottom-color:var(--c-m2)}
.tm .formula button.t[data-owner="sdk"]{border-bottom-color:var(--accent)}
.tm .formula button.t[data-owner="fix"]{border-bottom-color:var(--muted)}
.tm .formula button.t[aria-pressed="true"]{background:var(--accent-soft)}
.tm .terms{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:10px 22px;margin:14px 0;padding:0;list-style:none}
.tm .terms li{font-size:.9rem;padding:4px 0;border-top:1px solid var(--rule)}
.tm .terms li.active{border-top-color:var(--accent);background:var(--accent-soft)}
.tm .terms li b{font-family:var(--f-display);font-size:1.05rem}
.tm .panels{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,400px),1fr));gap:22px;margin-top:16px}
.tm .panel{min-width:0}
.tm .panel h3{margin:0 0 6px;font-size:1.1rem}
.tm .btnrow.flush{margin:0}
.tm .controls.tight{margin:6px 0}
/* pipeline */
.tm .flow{list-style:none;padding:0;margin:20px 0;display:grid;gap:0}
.tm .flow li{position:relative;display:grid;grid-template-columns:44px 1fr;gap:12px;padding:12px 0}
.tm .flow li:not(:last-child)::after{content:"";position:absolute;left:21px;top:52px;bottom:-6px;width:2px;background:var(--ink)}
.tm .flow li:not(:last-child)::before{content:"";position:absolute;left:16px;bottom:-8px;border:6px solid transparent;border-top:8px solid var(--ink);z-index:1}
.tm .flow .dot{width:44px;height:44px;border-radius:50%;border:2px solid var(--ink);display:grid;place-items:center;font-family:var(--f-mono);font-size:.82rem;background:var(--paper)}
.tm .flow h3{font-size:1.05rem;margin-top:4px}
.tm .flow p{margin:.25em 0;font-size:.92rem;color:var(--ink-2)}
.tm .chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.tm .chip{font-family:var(--f-mono);font-size:.75rem;padding:2px 8px;border:1px solid var(--rule);border-radius:2px;background:var(--paper)}
.tm .chip.v{border-color:var(--ok);color:var(--ok)} .tm .chip.c{border-color:var(--c-m2);color:var(--c-m2)} .tm .chip.u{border-color:var(--muted);color:var(--muted)} .tm .chip.d{border-color:var(--bad);color:var(--bad)}
.tm .tm-note{font-size:.9rem;border-top:1px solid var(--accent);border-bottom:1px solid var(--accent);padding:8px 0;margin:16px 0}
.tm .tm-foot{margin-top:50px;font-size:.82rem;color:var(--muted);border-top:1px solid var(--rule);padding-top:14px;max-width:none}
/* section 2: the full constituent set and the counts */
.tm .tm-full{margin:16px 0;border-top:1px solid var(--rule);border-bottom:1px solid var(--rule)}
.tm .tm-full summary{cursor:pointer;padding:10px 0;font-weight:600;font-size:.95rem}
.tm .tm-full summary:hover{color:var(--accent)}
.tm .tm-full .tbl{margin-top:4px}
.tm #s2-full td.sp{font-family:var(--f-body);color:var(--ink-2);text-align:left}
.tm #s2-full td.what{font-family:var(--f-body);text-align:left;white-space:normal;min-width:16em}
.tm #s2-full th:nth-child(5),.tm #s2-full th:nth-child(6){text-align:left}
.tm #s2-full tr.fig-row td{color:var(--ink);font-weight:500}
.tm .pill.figmark{border:1px solid var(--accent);color:var(--accent);font-size:.66rem;padding:0 5px;vertical-align:1px}
.tm .tm-sub{margin:26px 0 4px;font-size:1.15rem}
.tm .tm-counts{margin:.4em 0 .8em;padding-left:1.2em;font-size:.95rem}
.tm .tm-counts li{margin:.3em 0}
@media (prefers-reduced-motion: reduce){.tm *{scroll-behavior:auto!important;transition:none!important}}
