/* Plumpy’s Pump — css/styles.css */

:root {
  --paper: #E5E6E2;
  --surface: #F7F7F4;
  --field: #FFFFFF;
  --ink: #1B1C1F;
  --ink-2: #595D64;
  --line: #CFD1CC;
  --fig: #1B1C1F;
  --fig-far: #A2A5AA;
  --prop: #A3A8AE;
  --prop-fill: #DADCD7;
  --cable: #4A4E54;
  --hub: #26272A;
  --danger: #B3261E;

  --acc: #D2392C;
  --acc-edge: #8E2117;
  --acc-ink: #FFFFFF;
  --acc-soft: color-mix(in srgb, var(--acc) 11%, var(--surface));
  --acc-far: color-mix(in srgb, var(--acc) 45%, var(--surface));

  --display: 'Big Shoulders Display', 'Oswald', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 14px;
  --tabs-h: 64px;
  color-scheme: light;
}

/* Day colours follow calibrated plate colours */
[data-day="mon"] { --acc: #D2392C; --acc-edge: #8E2117; --acc-ink: #FFFFFF; }
[data-day="tue"] { --acc: #2360C5; --acc-edge: #143D80; --acc-ink: #FFFFFF; }
[data-day="thu"] { --acc: #EBB11A; --acc-edge: #8F6704; --acc-ink: #1B1C1F; }
[data-day="fri"] { --acc: #22915A; --acc-edge: #135C37; --acc-ink: #FFFFFF; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131416; --surface: #1C1E21; --field: #24272B; --ink: #ECEDE9; --ink-2: #A1A5AB; --line: #2D3034;
    --fig: #ECEDE9; --fig-far: #5E6268; --prop: #6D737A; --prop-fill: #2A2D31; --cable: #B6BBC1; --hub: #0D0E0F;
    --danger: #F2B8B5; color-scheme: dark;
  }
  :root:not([data-theme="light"])[data-day="tue"] { --acc: #3474DB; }
}
:root[data-theme="dark"] {
  --paper: #131416; --surface: #1C1E21; --field: #24272B; --ink: #ECEDE9; --ink-2: #A1A5AB; --line: #2D3034;
  --fig: #ECEDE9; --fig-far: #5E6268; --prop: #6D737A; --prop-fill: #2A2D31; --cable: #B6BBC1; --hub: #0D0E0F;
  --danger: #F2B8B5; color-scheme: dark;
}
:root[data-theme="dark"][data-day="tue"] { --acc: #3474DB; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--body); font-size: 16px; line-height: 1.45;
  color: var(--ink); background: var(--paper);
  padding-top: env(safe-area-inset-top);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2.5px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
#view:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap {
  max-width: 560px; margin: 0 auto;
  padding: 0 18px calc(var(--tabs-h) + 96px + env(safe-area-inset-bottom));
}

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding-top: 14px; }
.brand img { display: block; width: 36px; height: 36px; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1; letter-spacing: .01em; }
.about { padding-top: 8px; border-top: 1px solid var(--line); }
.about img { display: block; width: min(300px, 100%); height: auto; margin: 18px auto 0; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}

/* ---------- Hero: the day plate ---------- */
.hero { display: grid; grid-template-columns: 108px 1fr; gap: 16px; align-items: center; padding: 16px 0 16px; }
.plate { width: 108px; height: 108px; transform: rotate(var(--spin, 0deg)); transition: transform .7s cubic-bezier(.2, .8, .2, 1); }
.plate svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plate-txt { font-family: var(--display); font-weight: 800; font-size: 12.5px; letter-spacing: 2.4px; }
.hero-day { margin: 0; font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1; color: var(--ink-2); }
.hero h1 { margin: 4px 0 8px; font-family: var(--display); font-weight: 900; font-size: clamp(36px, 10.5vw, 52px); line-height: .9; letter-spacing: -.005em; }
.hero-date { margin: 0; font-size: 14px; color: var(--ink-2); }

/* ---------- Day tabs ---------- */
.daytabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 14px; }
.daytab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 0 6px; border: 1.5px solid transparent; border-radius: 12px; background: none;
  font-weight: 600; font-size: 14px; color: var(--ink-2);
}
.daytab .dot {
  position: relative; width: 24px; height: 24px; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 5px color-mix(in srgb, #000 16%, var(--c));
}
.daytab .dot::after { content: ''; position: absolute; inset: 8.5px; border-radius: 50%; background: var(--paper); }
.daytab .tmark { min-height: 15px; font-size: 11px; font-weight: 600; line-height: 15px; color: var(--ink-2); }
.daytab[aria-pressed="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }

/* ---------- Week selector ---------- */
.weeks { display: flex; align-items: center; gap: 6px; margin: 0 0 16px; }
.weeks-lbl { margin-right: 4px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.wk {
  position: relative; width: 42px; height: 42px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1;
}
.wk.is-now::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--acc); }
.wk[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Standard / science-backed switch ---------- */
.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 0 14px; padding: 4px;
  border-radius: 12px; background: color-mix(in srgb, var(--ink) 7%, var(--paper));
}
.modes button { height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 15px; color: var(--ink-2); }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.modes button[data-mode="sci"][aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--acc), 0 0 0 1px var(--line); }

/* ---------- Notes ---------- */
.note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 14px; padding: 10px 12px; border-left: 4px solid var(--acc); border-radius: 10px;
  background: var(--surface); font-size: 14px;
}
.note p { margin: 0; }

/* ---------- Inputs & buttons ---------- */
.num {
  display: flex; align-items: center; gap: 4px; height: 46px; padding: 0 10px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--field);
}
.num:focus-within { border-color: var(--acc); }
.num input {
  width: 100%; min-width: 0; border: 0; outline: none; background: transparent;
  font-size: 17px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums;
}
.num input::placeholder { color: var(--ink-2); opacity: .55; font-weight: 500; }
.num > span { font-size: 13px; color: var(--ink-2); }
.btn {
  height: 46px; padding: 0 16px; border: 0; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-weight: 700; white-space: nowrap;
}
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger { color: var(--danger); }
.chip {
  flex: none; display: inline-flex; align-items: center; height: 34px; padding: 0 13px;
  border: 1.5px solid var(--ink); border-radius: 999px; background: transparent;
  font-weight: 700; font-size: 14px; white-space: nowrap;
}

/* ---------- Weigh-in ---------- */
.weigh {
  display: grid; grid-template-columns: 1fr 104px auto; gap: 10px; align-items: center;
  margin: 0 0 18px; padding: 10px 10px 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
}
.weigh label { font-weight: 600; font-size: 15px; line-height: 1.25; }
.weigh small { display: block; margin-top: 2px; font-weight: 400; font-size: 13px; color: var(--ink-2); }

/* ---------- Warm-up / cooldown ---------- */
.aside summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
  font-weight: 600; cursor: pointer; list-style: none;
}
.aside summary::-webkit-details-marker { display: none; }
.aside summary::after { content: '+'; font-size: 22px; line-height: 1; color: var(--ink-2); }
.aside[open] summary::after { content: '\2013'; }
.aside ul { margin: 10px 0 8px; padding-left: 20px; color: var(--ink-2); }
.aside li { margin-bottom: 4px; }
.aside-end { margin-top: 6px; }

/* ---------- Exercise list ---------- */
.exlist { list-style: none; margin: 0; padding: 0; }
.ex { border-bottom: 1px solid var(--line); scroll-margin-top: calc(12px + env(safe-area-inset-top)); }
.ex-head {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  width: 100%; padding: 14px 2px; border: 0; background: none; text-align: left;
}
.ex-num { justify-self: center; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1; color: var(--ink-2); }
.ex.is-main .ex-num {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--acc); color: var(--acc-ink); font-size: 22px;
}
.ex-name { display: block; font-weight: 600; font-size: 17px; line-height: 1.25; }
.ex-meta { display: block; margin-top: 3px; font-size: 14px; color: var(--ink); }
.ex-load { display: block; font-size: 13px; color: var(--ink-2); }
.ex-tag {
  display: inline-block; margin-right: 4px; padding: 0 6px; border-radius: 5px;
  background: var(--acc-soft); font-size: 12px; font-weight: 700; line-height: 20px;
}
.ex-tag.is-sci { background: transparent; box-shadow: inset 0 0 0 1.5px var(--acc); }
.ex.is-done .ex-name { color: var(--ink-2); }
.dots { display: flex; gap: 4px; }
.dots i { display: block; width: 9px; height: 9px; border: 1.5px solid var(--ink-2); border-radius: 50%; }
.dots i.on { background: var(--acc); border-color: var(--acc); }

.ex.is-open { margin: 8px -10px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ex-body { padding: 0 0 18px; }

/* ---------- Demo panel ---------- */
.demo { padding: 8px 8px 10px; border-radius: 12px; background: var(--acc-soft); }
.fig { display: block; width: 100%; height: 210px; }
.demo-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 6px 0; font-size: 13px; color: var(--ink-2); }
.demo-foot a { color: var(--ink); font-weight: 700; text-underline-offset: 3px; }
.steps { margin: 14px 0 8px; padding-left: 22px; }
.steps li { margin: 0 0 6px; padding-left: 2px; }
.steps li::marker { font-family: var(--display); font-weight: 800; color: var(--ink-2); }
.tip { margin: 8px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--paper); font-size: 14px; }

/* ---------- Logging ---------- */
.log { padding-top: 14px; border-top: 1px solid var(--line); }
.ramp, .hint { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.effort { color: var(--ink); }
.lastline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; font-size: 14px; }
.setrow { display: grid; grid-template-columns: 44px 1fr 1fr 50px; gap: 8px; align-items: center; margin-bottom: 8px; }
.setrow .lbl { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.chk {
  display: grid; place-items: center; width: 50px; height: 46px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--field);
}
.chk svg { width: 22px; height: 22px; stroke: var(--ink-2); }
.chk[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); }
.chk[aria-pressed="true"] svg { stroke: var(--acc-ink); }
.platecalc { min-height: 20px; margin: 6px 0 0; font-size: 14px; font-weight: 600; }
.setbtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.setbtn {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 54px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--field); font-weight: 700;
}
.setbtn svg { width: 18px; height: 18px; stroke: currentColor; }
.setbtn[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }

.finish {
  width: 100%; height: 58px; margin: 24px 0 8px; border: 0; border-radius: var(--r);
  background: var(--acc); color: var(--acc-ink);
  font-family: var(--display); font-weight: 800; font-size: 25px; letter-spacing: .01em;
}
.finish.is-done { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.saved-line { margin: 0; text-align: center; font-size: 14px; color: var(--ink-2); }

/* ---------- Pages ---------- */
.page-h { margin: 24px 0 8px; font-family: var(--display); font-weight: 900; font-size: 48px; line-height: .92; }
.lead { max-width: 46ch; margin: 0 0 18px; color: var(--ink-2); }
.sec { margin: 0 0 28px; }
.sec h2 { margin: 0 0 10px; font-family: var(--display); font-weight: 800; font-size: 27px; line-height: 1; }
.sec p { max-width: 60ch; }
.panel { padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 4px; }
.stat b { display: block; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-2); }
.chart { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--body); font-size: 10.5px; fill: var(--ink-2); }
.rows { list-style: none; margin: 10px 0 0; padding: 0; }
.rows li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px;
  border-top: 1px solid var(--line); font-size: 15px; font-variant-numeric: tabular-nums;
}
.rows .r { text-align: right; }
.del { width: 36px; height: 36px; margin-left: 4px; border: 0; background: none; font-size: 20px; color: var(--ink-2); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.seg button { height: 38px; padding: 0 13px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.empty { margin: 4px 0; font-size: 15px; color: var(--ink-2); }

.weekdone { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; font-size: 14px; font-weight: 600; }
.weekdone .dot { position: relative; display: block; width: 44px; height: 44px; margin: 0 auto 6px; border-radius: 50%; border: 2px dashed var(--line); }
.weekdone .on .dot { border: 0; background: var(--c); box-shadow: inset 0 0 0 8px color-mix(in srgb, #000 16%, var(--c)); }
.weekdone .on .dot::after { content: ''; position: absolute; inset: 16px; border-radius: 50%; background: var(--surface); }

/* Rotation page */
.wkblock { padding: 12px 0 6px; border-top: 1px solid var(--line); }
.wkblock h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; font-family: var(--display); font-weight: 800; font-size: 25px; }
.wkblock.is-now { margin: 0 -12px; padding: 12px 12px 6px; border-top-color: transparent; border-radius: 12px; background: var(--acc-soft); }
.wkblock.is-now + .wkblock { border-top-color: transparent; }
.now-tag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--body); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.now-tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--acc); }
.plist { list-style: none; margin: 0; padding: 0; }
.plist button { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 0; border: 0; background: none; text-align: left; }
.plist .pn { font-weight: 600; }
.plist .ps { flex: none; max-width: 45%; font-size: 13px; color: var(--ink-2); text-align: right; }

/* Settings */
.field { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.field > label, .field > .fl { font-weight: 600; }
.field small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-2); }
.field .num { width: 120px; flex: none; }
.field input[type="date"], .field input[type="text"], .field select {
  height: 46px; max-width: 190px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--field); font-size: 16px;
}
.field input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--acc); flex: none; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- Tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line); background: var(--surface);
}
.tabs-in { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; height: var(--tabs-h); margin: 0 auto; }
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::before { content: ''; position: absolute; top: 0; left: 32%; right: 32%; height: 3px; border-radius: 0 0 3px 3px; background: var(--acc); }

/* ---------- Rest timer ---------- */
.rest {
  position: fixed; left: 12px; right: 12px; z-index: 25;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  display: flex; align-items: center; gap: 10px; max-width: 536px; height: 58px; margin: 0 auto; padding: 0 8px 0 16px;
  overflow: hidden; border-radius: 14px; background: var(--ink); color: var(--paper);
}
.rest[hidden] { display: none; }
.rest-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--acc); opacity: .4; transition: width .25s linear; }
.rest > :not(.rest-fill) { position: relative; }
.rest-time { font-family: var(--display); font-weight: 800; font-size: 30px; font-variant-numeric: tabular-nums; }
.rest-lbl { flex: 1; font-size: 14px; font-weight: 600; }
.rest button {
  height: 40px; padding: 0 12px; border: 1px solid color-mix(in srgb, var(--paper) 35%, transparent); border-radius: 10px;
  background: transparent; color: var(--paper); font-weight: 700;
}

/* ---------- Toast & sheet ---------- */
.toast {
  position: fixed; left: 50%; z-index: 30; max-width: calc(100% - 32px);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 78px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--paper);
  font-size: 14px; font-weight: 600; text-align: center;
  opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .45); }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: var(--surface);
}
.sheet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sheet-top h2 { margin: 6px 0 4px; font-family: var(--display); font-weight: 800; font-size: 31px; line-height: 1; }
.sheet-top p { margin: 0; color: var(--ink-2); font-size: 14px; }
.x { flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--paper); font-size: 24px; line-height: 1; }

@media (max-width: 370px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  .hero { grid-template-columns: 88px 1fr; }
  .plate { width: 88px; height: 88px; }
  .weigh { grid-template-columns: 1fr 96px; }
  .weigh .btn { grid-column: 1 / -1; }
  .wk { width: 38px; height: 38px; }
  .weeks-lbl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
