/* Player — "Topo". Photo on top, a state field below: coral while you work, teal while you rest,
   chalk while it waits for you. State lives on [data-player-state]; the field snaps, it never fades. */

.player-body { overflow: hidden; }

.player {
  --field: var(--work);
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--navy); color: var(--chalk);
}
.player[data-player-state="rest"] { --field: var(--rest); }
.player[data-player-state="waiting"] { --field: var(--chalk); }

/* route strip */
.p-top {
  height: calc(92px + env(safe-area-inset-top)); flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: env(safe-area-inset-top) max(24px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
.p-exit { width: var(--tap); height: var(--tap); border: 0; background: none; color: var(--chalk); display: grid; place-items: center; cursor: pointer; }
.p-exit svg { width: 28px; height: 28px; }
.p-route { flex: 1; display: flex; align-items: center; min-width: 0; }
.p-hold { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--chalk-55); flex: none; box-sizing: border-box; }
.p-hold.done { background: var(--chalk); border-color: var(--chalk); }
.p-hold.now { border: 5px solid var(--work); transform: scale(1.25); }
.p-seg { flex: 1; height: 0; border-top: 2px dashed var(--chalk-55); min-width: 10px; }
.p-seg.resting { height: 6px; border: 0; background: var(--rest); }
.p-clock { min-width: 86px; text-align: right; font-size: 30px; font-weight: 700; font-stretch: var(--cond); }

/* ready */
.p-ready {
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px;
  padding: 24px max(var(--gutter), env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  max-width: 900px; width: 100%; margin: 0 auto;
}
.p-ready h1 { font-size: clamp(56px, 10vw, 96px); line-height: .92; font-weight: 800; font-stretch: var(--cond); }
.p-ready-meta { font-size: 19px; font-weight: 600; }
.p-start { min-height: 112px; font-size: 44px; justify-content: space-between; padding: 0 36px; margin-top: 10px; }
.p-start svg { width: 40px; height: 40px; }
.p-hint { color: var(--chalk-72); font-size: 17px; }

/* stage */
.p-stage { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 42fr) minmax(0, 58fr); }
.p-stage[hidden] { display: none; }

.p-visual { position: relative; min-height: 0; overflow: hidden; background: var(--navy-3); }
.p-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; }
.p-visual img.hidden-frame { opacity: 0; }
.p-side {
  position: absolute; left: 32px; bottom: 28px;
  display: inline-flex; align-items: center; height: 84px; padding: 0 30px;
  background: var(--field); color: var(--ink);
  font-stretch: var(--cond); font-size: 64px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.p-upnext { position: absolute; left: 32px; top: 24px; height: 46px; font-size: 24px; padding: 0 18px; }

/* no picture: the block's rounds/sets as tape tiles (the hangboard repeater view) */
.p-sets { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 max(40px, env(safe-area-inset-right)) 0 max(40px, env(safe-area-inset-left)); gap: 0; }
.p-sets .tile {
  flex: 1; height: min(150px, 60%); max-width: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-stretch: var(--cond); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.p-sets .tile b { font-size: 80px; line-height: .9; font-weight: 900; }
.p-sets .tile span { font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.p-sets .tile.done { background: var(--chalk); color: var(--ink); }
.p-sets .tile.now { background: var(--work); color: var(--ink); }
.p-sets .tile.todo { background: var(--navy-2); color: var(--chalk-72); }
.p-sets .gap { width: 32px; height: 8px; background: var(--rest); flex: none; }

/* the state field: a level of --field colour (coral, teal or chalk) over the navy wall.
   Rep work, rest and waiting are full; timed work drains it like a level meter. */
.p-field { --fill: 100%; position: relative; min-height: 0; background: var(--navy); overflow: hidden; }
.p-field-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 28px max(56px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(40px, env(safe-area-inset-left));
}
.p-ink { transition: clip-path .25s linear; }
.p-chalk { color: var(--chalk); }
/* the level: an opaque copy in the field colour, clipped from the bottom; taps fall through to the chalk layer */
.p-ink { color: var(--ink); background: var(--field); clip-path: inset(calc(100% - var(--fill)) 0 0 0); pointer-events: none; }
.p-ticks { position: absolute; right: 0; top: 0; bottom: 0; width: 28px; display: none; flex-direction: column; justify-content: space-evenly; }
.p-ticks i { display: block; height: 2px; background: currentColor; opacity: .55; }
.player[data-player-state="work"][data-player-timed="true"] .p-ticks { display: flex; }
.p-label-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.p-label { font-size: 22px; font-weight: 700; }
.p-pause { min-height: 48px; padding: 0 18px; border: 2px solid currentColor; border-radius: var(--radius); background: transparent; color: inherit; font: 700 18px var(--font); cursor: pointer; }
.p-info { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-top: 18px; }
.p-words { padding-bottom: 22px; min-width: 0; }
.p-name { font-size: clamp(44px, 8vw, 68px); line-height: .95; font-weight: 800; font-stretch: var(--cond); }
.p-name.long { font-size: clamp(36px, 6vw, 52px); }
.p-unit { margin-top: 12px; font-size: 32px; font-weight: 700; font-stretch: var(--cond); }
.p-unit:empty { display: none; }
.p-cue { margin-top: 6px; font-size: 20px; font-weight: 500; }
.p-number-col { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.p-number { font-size: var(--player-number); line-height: .78; font-weight: 900; font-stretch: var(--cond); letter-spacing: -.02em; }
.p-number-unit { font-size: 28px; font-weight: 800; font-stretch: var(--cond); margin-top: 10px; }
.p-number-unit:empty { display: none; }
.p-then { margin-top: 18px; padding-top: 14px; border-top: 2px solid color-mix(in srgb, currentColor 35%, transparent); font-size: 21px; font-weight: 600; }
.p-then:empty { display: none; }
.p-then b { font-weight: 800; }
.p-controls { margin-top: auto; padding-top: 18px; display: flex; align-items: center; justify-content: center; gap: 28px; }
.p-ctl { width: 96px; height: 96px; border-radius: 50%; border: 3px solid currentColor; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; flex: none; }
.p-ctl svg { width: 36px; height: 36px; }
.p-main { height: 108px; min-width: 300px; border: 0; border-radius: 54px; font: 900 48px var(--font); font-stretch: var(--cond); cursor: pointer; font-variant-numeric: tabular-nums; }
.p-ink .p-main { background: var(--ink); color: var(--field); }
.p-chalk .p-main { background: var(--chalk); color: var(--navy); }
.p-main:active, .p-ctl:active { transform: scale(.96); }
.player[data-paused="true"] .p-number { opacity: .4; }

/* landscape: photo left, field right */
@media (orientation: landscape) {
  .p-stage { grid-template-rows: none; grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); }
  .p-number { font-size: clamp(200px, 26vw, 290px); }
  .p-name { font-size: clamp(40px, 5vw, 60px); }
  .p-controls { gap: 22px; }
  .p-main { min-width: 240px; }
}

/* summary */
.p-summary {
  flex: 1; overflow-y: auto; width: 100%; max-width: 820px; margin: 0 auto;
  padding: 28px max(var(--gutter), env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  display: flex; flex-direction: column;
}
.p-summary[hidden] { display: none; }
.p-sum-b { display: flex; flex-direction: column; }
@media (orientation: landscape) {
  .p-summary { max-width: 1133px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 48px; align-items: start; }
  .p-summary .p-sum-h:first-child { margin-top: 0; }
  .p-sent { margin-top: 28px; }
}
.p-sent { margin-top: 48px; font-size: clamp(140px, 26vw, 200px); line-height: .8; font-weight: 900; font-stretch: var(--cond); letter-spacing: -.02em; }
.p-sum-line { margin-top: 22px; font-size: 24px; font-weight: 600; }
.p-sum-h { margin: 44px 0 14px; font-size: 22px; font-weight: 600; }
.p-rpe { display: flex; gap: 10px; }
.p-rpe button { flex: 1; height: 96px; border-radius: var(--radius); border: 2px solid var(--chalk-40); background: transparent; color: var(--chalk); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; font-family: var(--font); }
.p-rpe b { font-stretch: var(--cond); font-size: 26px; font-weight: 800; }
.p-rpe span { font-size: 14px; color: var(--chalk-72); }
.p-rpe button[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--ink); }
.p-rpe button[aria-pressed="true"] span { color: rgba(15, 26, 43, .75); }
.p-error { margin-top: 12px; }
.p-save { margin-top: 28px; }

/* ---------- Phone (iPhone portrait, ≤ 520px): same player, sized for one hand and a 402pt screen ---------- */

@media (max-width: 520px) {
  .p-top { height: calc(64px + env(safe-area-inset-top)); gap: 10px; padding-right: max(16px, env(safe-area-inset-right)); padding-left: max(4px, env(safe-area-inset-left)); }
  .p-exit { width: 48px; height: 48px; }
  .p-clock { min-width: 60px; font-size: 22px; }
  .p-hold.now { transform: scale(1.1); }

  .p-ready { gap: 16px; }
  .p-ready h1 { font-size: 44px; }
  .p-ready .route { --k: .55; }
  .p-start { min-height: 88px; font-size: 34px; }

  .p-stage { grid-template-rows: minmax(0, 44fr) minmax(0, 56fr); }
  .p-side { left: 16px; bottom: 16px; height: 56px; padding: 0 20px; font-size: 40px; }
  .p-upnext { left: 16px; top: 14px; height: 36px; font-size: 18px; padding: 0 12px; }
  .p-sets { padding: 0 16px; }
  .p-sets .tile { height: min(110px, 60%); }
  .p-sets .tile b { font-size: 52px; }
  .p-sets .tile span { font-size: 13px; }
  .p-sets .gap { width: 14px; height: 6px; }

  .p-field-inner { padding: 18px max(30px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .p-label { font-size: 16px; }
  .p-pause { min-height: 40px; padding: 0 12px; font-size: 15px; }
  /* the field is taller than its content: centre the step between the label and the controls */
  .p-info { gap: 12px; margin-top: auto; padding-top: 10px; }
  .p-words { padding-bottom: 12px; }
  .p-name { font-size: 34px; }
  .p-name.long { font-size: 28px; }
  .p-unit { margin-top: 8px; font-size: 22px; }
  .p-cue { font-size: 15px; }
  .p-number-unit { font-size: 18px; margin-top: 6px; }
  .p-then { margin-top: 12px; padding-top: 10px; font-size: 15px; }
  .p-ticks { width: 18px; }

  .p-controls { gap: 12px; padding-top: 12px; }
  .p-ctl { width: 68px; height: 68px; }
  .p-ctl svg { width: 28px; height: 28px; }
  .p-main { flex: 1; min-width: 0; height: 84px; font-size: 36px; }

  .p-summary { padding-top: 16px; }
  .p-summary .route { --k: .55; }
  .p-sent { margin-top: 28px; font-size: 104px; }
  .p-sum-line { font-size: 18px; }
  .p-sum-h { margin: 32px 0 10px; font-size: 18px; }
  .p-rpe { gap: 6px; }
  .p-rpe button { height: 72px; padding: 0 2px; }
  .p-rpe b { font-size: 17px; }
  .p-rpe span { font-size: 11px; }
}
