/* ============================================================
   TRENING — PPL · editorial gym app
   Ink black · bone white · REC red
   Display: Archivo (variable, expanded 900) · Utility: JetBrains Mono
   ============================================================ */

:root {
  --ink: #0b0b0d;
  --ink-2: #131316;
  --ink-3: #1c1c21;
  --line: #26262c;
  --bone: #f2efe9;
  --bone-dim: #8f8d88;
  --rec: #ff3b30;
  --rec-deep: #b3271f;
  --ok: #3ddc84;
  --radius: 18px;
  --pad: clamp(18px, 5vw, 32px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: 'Archivo', sans-serif;
  font-variation-settings: 'wdth' 100, 'wght' 500;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

::selection { background: var(--rec); color: var(--bone); }

/* ---------- grain overlay ---------- */
.grain {
  position: fixed; inset: -50%;
  width: 200%; height: 200%;
  pointer-events: none;
  z-index: 9;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 1.2s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(2%, -1%); }
}

/* ---------- red wipe transition ---------- */
.wipe {
  position: fixed; inset: 0;
  background: var(--rec);
  z-index: 100;
  transform: translateY(101%);
  pointer-events: none;
}
.wipe.run { animation: wipe-through .8s cubic-bezier(.77, 0, .18, 1); }
@keyframes wipe-through {
  0%   { transform: translateY(101%); }
  45%  { transform: translateY(0); }
  55%  { transform: translateY(0); }
  100% { transform: translateY(-101%); }
}

/* ---------- screens ---------- */
.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 20px) var(--pad) calc(env(safe-area-inset-bottom) + 26px);
  position: relative;
}
.screen.active { display: flex; }

/* ============================================================
   HOME
   ============================================================ */
.home-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; letter-spacing: 2.5px;
  color: var(--bone-dim);
}
.rec-badge { display: flex; align-items: center; gap: 8px; }
.rec-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--rec);
  box-shadow: 0 0 12px rgba(255, 59, 48, .8);
  animation: blink 1.6s infinite;
  flex: 0 0 auto;
}
@keyframes blink { 0%, 100% { opacity: 1 } 50% { opacity: .2 } }
.meta-right { font-size: 11px; }

.hero { margin: clamp(28px, 7vh, 64px) 0 10px; }
.hero-title {
  font-variation-settings: 'wdth' 118, 'wght' 900;
  font-size: clamp(58px, 17vw, 130px);
  line-height: .88;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  user-select: none;
}
.hero-title .line { display: block; overflow: hidden; }
.hero-title .line > span {
  display: inline-block;
  animation: rise .9s cubic-bezier(.19, 1, .22, 1) both;
}
.hero-title .line:nth-child(2) > span { animation-delay: .12s; }
.hero-title .indent { padding-left: .8em; }
.hero-title .ghost {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--bone-dim);
}
@keyframes rise {
  from { transform: translateY(110%); }
  to { transform: translateY(0); }
}
.hero-sub {
  margin-top: 18px;
  font-size: 11px; letter-spacing: 3px;
  color: var(--bone-dim);
  animation: fade-in .8s .4s both;
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

/* marquee */
.marquee {
  margin: 26px calc(var(--pad) * -1) 30px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
  padding: 9px 0;
}
.marquee-track {
  display: inline-block;
  font-size: 12px; letter-spacing: 4px;
  color: var(--rec);
  animation: marquee 18s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* day cards */
.day-list { display: flex; flex-direction: column; }
.day-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  text-align: left;
  padding: 22px 4px;
  border-bottom: 1px solid var(--line);
  transition: padding-left .25s cubic-bezier(.19, 1, .22, 1);
  animation: fade-in .7s both;
}
.day-card:nth-child(1) { animation-delay: .35s; }
.day-card:nth-child(2) { animation-delay: .45s; }
.day-card:nth-child(3) { animation-delay: .55s; }
.day-card:first-child { border-top: 1px solid var(--line); }
.day-card:active { padding-left: 14px; }
@media (hover: hover) {
  .day-card:hover { padding-left: 14px; }
  .day-card:hover .day-arrow { background: var(--rec); border-color: var(--rec); color: var(--bone); transform: rotate(-45deg); }
  .day-card:hover .day-name { color: var(--rec); }
}
.day-index {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--rec);
  letter-spacing: 1px;
  align-self: start;
  padding-top: 8px;
}
.day-name {
  font-variation-settings: 'wdth' 115, 'wght' 900;
  font-size: clamp(30px, 8.5vw, 44px);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1;
  transition: color .2s;
}
.day-desc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 1.5px;
  color: var(--bone-dim);
  margin-top: 7px;
  text-transform: uppercase;
}
.day-arrow {
  width: 46px; height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--bone-dim);
  transition: all .25s cubic-bezier(.19, 1, .22, 1);
}

.home-note {
  margin-top: auto;
  padding-top: 34px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
}
.note-tag {
  font-size: 10px; letter-spacing: 2px;
  color: var(--rec);
  border: 1px solid rgba(255, 59, 48, .4);
  border-radius: 99px;
  padding: 5px 10px;
  white-space: nowrap;
}
.home-note p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--bone-dim);
}

/* ============================================================
   WORKOUT
   ============================================================ */
#workout { overflow: hidden; }

.ghost-num {
  position: absolute;
  top: 42px; right: -12px;
  font-size: clamp(160px, 45vw, 340px);
  font-weight: 700;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px var(--line);
  z-index: 0;
  user-select: none;
  transition: opacity .3s;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  position: relative; z-index: 1;
}
.day-label {
  font-size: 11px; letter-spacing: 3px;
  color: var(--rec);
  display: flex; align-items: center; gap: 8px;
}
.day-label::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rec);
  animation: blink 1.6s infinite;
}
.quit {
  font-size: 10.5px; letter-spacing: 2px;
  color: var(--bone-dim);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 8px 14px;
  transition: border-color .2s, color .2s;
}
.quit:active { border-color: var(--rec); color: var(--rec); }

.progress-track {
  height: 3px;
  background: var(--line);
  margin: 18px 0 30px;
  position: relative; z-index: 1;
}
.progress-fill {
  height: 100%;
  background: var(--rec);
  width: 0%;
  transition: width .5s cubic-bezier(.19, 1, .22, 1);
  box-shadow: 0 0 10px rgba(255, 59, 48, .6);
}

.ex-stage { position: relative; z-index: 1; display: flex; flex-direction: column; flex: 1; }
.ex-stage.swap-out { animation: swap-out .22s ease both; }
.ex-stage.swap-in { animation: swap-in .38s cubic-bezier(.19, 1, .22, 1) both; }
@keyframes swap-out {
  to { opacity: 0; transform: translateX(-26px); }
}
@keyframes swap-in {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

.ex-counter {
  font-size: 11px; letter-spacing: 3px;
  color: var(--bone-dim);
  margin-bottom: 10px;
}
.ex-counter b { color: var(--rec); font-weight: 500; }

.ex-name {
  font-variation-settings: 'wdth' 112, 'wght' 900;
  font-size: clamp(36px, 10.5vw, 62px);
  line-height: .95;
  text-transform: uppercase;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  min-height: 1.9em;
}

.ex-scheme {
  font-size: clamp(19px, 5.5vw, 24px);
  font-weight: 700;
  margin-bottom: 14px;
}
.scheme-label { font-size: 10px; letter-spacing: 2px; color: var(--bone-dim); font-weight: 400; }

.ex-note {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--bone-dim);
  border-left: 2px solid var(--rec);
  padding-left: 14px;
  margin-bottom: 30px;
  max-width: 46ch;
}

/* sets */
.sets-row { display: flex; gap: 12px; margin-bottom: 10px; }
.set-btn {
  flex: 1;
  height: clamp(72px, 18vw, 96px);
  background: var(--ink-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  font-size: 19px; font-weight: 700;
  color: var(--bone-dim);
  transition: all .18s cubic-bezier(.19, 1, .22, 1);
  position: relative;
  overflow: hidden;
}
.set-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--rec);
  transform: translateY(101%);
  transition: transform .28s cubic-bezier(.19, 1, .22, 1);
  z-index: -1;
}
.set-btn.done {
  color: var(--bone);
  border-color: var(--rec);
}
.set-btn.done::after { transform: translateY(0); z-index: 0; }
.set-btn span { position: relative; z-index: 1; }
.set-btn:active { transform: scale(.95); }

.set-hint {
  font-size: 9.5px; letter-spacing: 2px;
  color: var(--bone-dim);
  opacity: .7;
  margin-bottom: 26px;
}

/* rest timer */
.rest {
  display: none;
  align-items: center;
  gap: 20px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 26px;
}
.rest.show { display: flex; animation: swap-in .3s cubic-bezier(.19, 1, .22, 1) both; }

.rest-ring { width: 84px; height: 84px; flex: 0 0 auto; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 6; }
.ring-fg {
  fill: none; stroke: var(--rec); stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.rest-inner { flex: 1; }
.rest-label { font-size: 10px; letter-spacing: 3px; color: var(--bone-dim); }
.rest-time {
  font-size: clamp(38px, 11vw, 50px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1.1;
}
.rest-time.low { color: var(--rec); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { opacity: .5 } }
.rest-skip {
  font-size: 10px; letter-spacing: 2px;
  color: var(--bone-dim);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 7px 14px;
  margin-top: 6px;
}
.rest-skip:active { border-color: var(--rec); color: var(--rec); }

/* nav */
.nav-row {
  display: flex; gap: 12px;
  margin-top: auto;
  position: relative; z-index: 1;
}
.nav-btn {
  border-radius: var(--radius);
  padding: 19px;
  font-variation-settings: 'wdth' 110, 'wght' 800;
  font-size: 15px;
  letter-spacing: 1px;
  transition: transform .12s, opacity .2s, background .2s;
}
.nav-btn:active { transform: scale(.97); }
.nav-btn.back {
  flex: 0 0 auto; width: 62px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--bone-dim);
  font-size: 22px;
}
.nav-btn.next {
  flex: 1;
  background: var(--rec);
  color: var(--bone);
  box-shadow: 0 8px 30px rgba(255, 59, 48, .25);
}
.nav-btn.next.subtle {
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--bone);
  box-shadow: none;
}
.nav-btn:disabled { opacity: .25; pointer-events: none; }

/* ============================================================
   DONE
   ============================================================ */
#done { justify-content: center; }
.done-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.done-tag {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 3px;
  color: var(--bone-dim);
  margin-bottom: 18px;
  animation: fade-in .6s both;
}
.done-title {
  font-variation-settings: 'wdth' 118, 'wght' 900;
  font-size: clamp(54px, 15vw, 110px);
  line-height: .9;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin-bottom: 34px;
  animation: swap-in .5s .1s cubic-bezier(.19, 1, .22, 1) both;
}
.done-stats {
  display: flex;
  gap: 0;
  width: 100%;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
  animation: fade-in .6s .25s both;
}
.stat {
  flex: 1;
  padding: 16px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.stat + .stat { border-left: 1px solid var(--line); padding-left: 18px; }
.stat-num { font-size: clamp(26px, 8vw, 38px); font-weight: 700; color: var(--rec); }
.stat-label { font-size: 9.5px; letter-spacing: 2px; color: var(--bone-dim); }
.done-sub {
  font-size: 14.5px; line-height: 1.6;
  color: var(--bone-dim);
  max-width: 32ch;
  margin-bottom: 34px;
  animation: fade-in .6s .35s both;
}
#btn-home { width: 100%; animation: fade-in .6s .45s both; }

/* ============================================================
   a11y / reduced motion
   ============================================================ */
button:focus-visible {
  outline: 2px solid var(--rec);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .grain, .marquee-track { animation: none !important; }
}

/* desktop: constrain to phone-ish column, keep it centered */
@media (min-width: 760px) {
  .screen { max-width: 640px; margin: 0 auto; }
  .ghost-num { right: 0; }
}
