/* ═══════════════════════════════════════════════
   REMAINING — a life, counted
   https://remaining.live
   ═══════════════════════════════════════════════ */

:root {
  --bg: #0b0b0a;
  --bg-raise: #111110;
  --ink: #e8e3d8;
  --ink-dim: #8f8a7e;
  --ink-faint: #55524a;
  --hair: #262521;
  --ember: #e25822;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
  --max: 1060px;
  --gutter: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button,
input { touch-action: manipulation; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 4px;
}

::selection { background: var(--ember); color: #0b0b0a; }

em { font-style: italic; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--ink-faint); }
a:hover { text-decoration-color: var(--ember); }

/* ── shared type ── */

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.section-title {
  font-size: clamp(2.4rem, 5.4vw, 4.2rem);
  font-weight: 300;
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0.5em 0 0.45em;
}

.section-sub {
  max-width: 34em;
  color: var(--ink-dim);
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  font-weight: 300;
}

/* ── buttons ── */

.btn-primary {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--ink);
  border: 1px solid var(--ink);
  padding: 1.05em 2.4em;
  min-height: 48px;
  cursor: pointer;
  transition: background 0.35s ease, color 0.35s ease, letter-spacing 0.35s ease;
}
.btn-primary:hover { background: transparent; color: var(--ink); letter-spacing: 0.3em; }

.btn-ghost {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 0.5em 0.2em;
  min-height: 44px;
  transition: color 0.3s ease;
}
.btn-ghost:hover { color: var(--ember); }

/* ═══════════ INTRO ═══════════ */

.intro {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 8vh var(--gutter);
}

.intro-inner { max-width: 620px; text-align: center; }

.intro-title {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0.55em 0 0.5em;
}

.intro-sub {
  color: var(--ink-dim);
  font-weight: 300;
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  max-width: 30em;
  margin: 0 auto 3.2em;
}

.entry {
  display: grid;
  gap: 1.9em;
  justify-items: center;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  padding: 2.6em 0;
}

.entry-row {
  display: flex;
  align-items: baseline;
  gap: 1.4em;
  width: 100%;
  max-width: 420px;
  justify-content: center;
  flex-wrap: wrap;
}

.entry-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  min-width: 5.5em;
  text-align: right;
}

#dob {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 300;
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink-faint);
  color: var(--ink);
  padding: 0.15em 0.1em 0.3em;
  min-height: 44px;
  outline: none;
  transition: border-color 0.3s;
}
#dob:focus { border-color: var(--ember); }

.span-control { display: flex; align-items: center; gap: 1.2em; }

.span-value {
  font-size: 1.5rem;
  font-weight: 300;
  min-width: 4.6em;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 44px;
  background: transparent;
  outline: none;
  touch-action: pan-x;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--ink-faint);
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--ink-faint);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
  cursor: pointer;
  margin-top: -8px;
  transition: transform 0.2s, background 0.2s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); background: var(--ember); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
  cursor: pointer;
}

.entry-note {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.intro-credit {
  margin-top: 3em;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* intro entrance */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  animation: rise 1.1s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}
.d1 { animation-delay: 0.15s; }
.d2 { animation-delay: 0.3s; }
.d3 { animation-delay: 0.45s; }
.d4 { animation-delay: 0.7s; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

/* ═══════════ HEADER ═══════════ */

.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px max(32px, env(safe-area-inset-right)) 20px max(32px, env(safe-area-inset-left));
  background: rgba(11, 11, 10, 0.82);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hair);
}

.wordmark {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.42em;
  white-space: nowrap;
}
.wordmark .wordmark-domain {
  color: #ff6b2c;
  font-weight: 600;
  text-shadow: 0 0 18px rgba(226, 88, 34, 0.28);
}

.head-actions { display: flex; gap: 1.6em; }

/* ═══════════ HERO ═══════════ */

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 14vh, 150px) var(--gutter) clamp(70px, 11vh, 120px);
}

.hero .kicker { margin-bottom: 2.4em; }

.hero-line {
  font-weight: 300;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  line-height: 1.25;
  margin-bottom: 0.9em;
}
.hero-line.dim { color: var(--ink-dim); }
.hero-line.dim .huge { color: var(--ink); opacity: 0.5; }

.huge {
  display: inline-block;
  font-size: clamp(3.4rem, 9.5vw, 7.6rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 0.06em;
}

.lifebar {
  position: relative;
  height: 1px;
  background: var(--hair);
  margin: 4.2em 0 1.6em;
}
.lifebar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--ink);
  transition: width 2.4s cubic-bezier(0.19, 1, 0.22, 1);
}
.lifebar-dot {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ember);
  transform: translate(-50%, -50%);
  transition: left 2.4s cubic-bezier(0.19, 1, 0.22, 1);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 88, 34, 0.5); }
  50% { box-shadow: 0 0 0 9px rgba(226, 88, 34, 0); }
}

.hero-meta {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

/* ═══════════ SECTIONS ═══════════ */

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(70px, 11vh, 130px) var(--gutter);
  border-top: 1px solid var(--hair);
}

.section-head { margin-bottom: 3.4em; }

/* ── grid section ── */

.grid-tools {
  display: flex;
  gap: 0.4em;
  margin-bottom: 2.2em;
}

.tab {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--hair);
  color: var(--ink-dim);
  padding: 0.75em 1.5em;
  min-height: 44px;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-color: var(--ink-dim); }

.grid-wrap { position: relative; }

#life-grid {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  cursor: crosshair;
}

#grid-now {
  position: absolute;
  background: var(--ember);
  pointer-events: none;
  animation: nowpulse 2.2s ease-in-out infinite;
}
@keyframes nowpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  #grid-now { animation: none; }
}

.grid-tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1.7;
  background: var(--bg-raise);
  border: 1px solid var(--hair);
  color: var(--ink);
  padding: 0.7em 1em;
  transform: translate(14px, -50%);
  white-space: nowrap;
}
.grid-tip .tip-dim { color: var(--ink-dim); display: block; }

.grid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2.2em;
  margin-top: 2.4em;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.grid-legend .sw {
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 0.7em;
  vertical-align: baseline;
}
.sw-past { background: var(--ink); }
.sw-now { background: var(--ember); border-radius: 50%; }
.sw-future { background: var(--ink-faint); opacity: 0.5; }

/* ── rituals ── */

.rituals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  border-top: 1px solid var(--hair);
  border-left: 1px solid var(--hair);
}

.ritual {
  border-right: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  padding: 2em 1.7em 1.8em;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  min-height: 200px;
  transition: background 0.4s ease;
}
.ritual:hover { background: var(--bg-raise); }

.ritual-num {
  font-size: clamp(2.6rem, 4.4vw, 3.6rem);
  font-weight: 200;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.ritual-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 0.6em;
}

.ritual-num.is-big { font-size: clamp(1.9rem, 3vw, 2.5rem); padding-top: 0.35em; }

.ritual-note {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-top: auto;
  padding-top: 1.2em;
}

.ritual-freq {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-top: auto;
  padding-top: 1em;
}
.ritual-freq span {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.freq-btn {
  font-family: var(--mono);
  width: 32px; height: 32px;
  background: none;
  border: 1px solid var(--hair);
  color: var(--ink-dim);
  cursor: pointer;
  line-height: 1;
  transition: color 0.25s, border-color 0.25s;
}
.freq-btn:hover { color: var(--ember); border-color: var(--ink-dim); }

/* ── where it goes ── */

.where-bar {
  display: flex;
  width: calc(100% + (var(--gutter) * 2));
  height: 32px;
  gap: 2px;
  margin: 0 calc(var(--gutter) * -1) 2.8em;
  background: var(--bg);
}
.where-bar .seg { min-width: 2px; transition: width 0.6s cubic-bezier(0.19, 1, 0.22, 1); }

.seg-sleep   { background: #58618f; }
.seg-work    { background: #4f7f7a; }
.seg-screens { background: #9a6fa5; }
.seg-eat     { background: #c6924b; }
.seg-other   { background: var(--ember); }

.where-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.4em 2.4em;
  margin-bottom: 3em;
}
.where-list li {
  display: flex;
  align-items: baseline;
  gap: 0.8em;
  border-top: 1px solid var(--hair);
  padding-top: 1em;
}
.where-list .sw { width: 9px; height: 9px; flex: none; align-self: center; }
.where-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  flex: 1;
}
.where-val {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.where-list li:last-child .where-val { color: var(--ember); }

.screen-block {
  border-top: 1px solid var(--hair);
  padding-top: 1.2em;
  margin-bottom: 1.6em;
}
.screen-summary {
  display: flex;
  align-items: baseline;
  gap: 0.8em;
  flex-wrap: wrap;
  margin-bottom: 0.8em;
}
.screen-summary .sw { width: 9px; height: 9px; display: inline-block; margin-right: 0.8em; }
.screen-summary-label,
.screen-summary-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.screen-summary-label { flex: 1; }
.screen-summary-years {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.screen-summary-meta { color: var(--ink-faint); }
.screen-meter {
  width: calc(100% + (var(--gutter) * 2));
  height: 12px;
  background: rgba(232, 227, 216, 0.12);
  box-shadow: inset 0 0 0 1px rgba(232, 227, 216, 0.08);
  margin: 0 calc(var(--gutter) * -1) 1.6em;
  overflow: hidden;
}
.screen-meter-fill {
  width: 0;
  height: 100%;
  transition: width 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.where-ctl {
  display: flex;
  align-items: center;
  gap: 1.4em;
  flex-wrap: wrap;
  margin-bottom: 0.8em;
}
.where-ctl input[type="range"] {
  flex: 1 1 220px;
  width: auto;
  min-width: 0;
}
.where-ctl-val {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.where-ctl-val b { color: var(--ink); font-weight: 500; }

.fine {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  line-height: 1.9;
  color: var(--ink-faint);
  max-width: 46em;
}

/* ── the tail end ── */

.tailend { max-width: 780px; }

.tl-sentence {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 300;
  line-height: 1.5;
}

.tl-sentence input {
  font-family: var(--serif);
  font-size: inherit;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink-faint);
  color: var(--ember);
  width: 2.6ch;
  text-align: center;
  padding: 0 0.05em 0.08em;
  outline: none;
  transition: border-color 0.3s;
}
.tl-sentence input:focus { border-color: var(--ember); }
.tl-sentence input::-webkit-outer-spin-button,
.tl-sentence input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tl-sentence input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.tl-result {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  margin-top: 0.6em;
}

.tl-note {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-top: 1.4em;
}

/* ── dates ── */

.markers {
  list-style: none;
  border-top: 1px solid var(--hair);
}

.markers li {
  display: grid;
  grid-template-columns: minmax(9em, 14em) 1fr;
  gap: 2em;
  align-items: baseline;
  padding: 2em 0;
  border-bottom: 1px solid var(--hair);
}

.mk-date {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.markers p {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 300;
}

/* ═══════════ FOOTER ═══════════ */

.site-foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 60px var(--gutter) max(70px, calc(48px + env(safe-area-inset-bottom)));
  border-top: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  display: flex;
  justify-content: space-between;
  gap: 2em;
  flex-wrap: wrap;
}
.foot-note { color: var(--ink-faint); }

/* ═══════════ SCROLL REVEALS ═══════════ */

.io-reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 1.1s cubic-bezier(0.19, 1, 0.22, 1),
              transform 1.1s cubic-bezier(0.19, 1, 0.22, 1);
}
.io-reveal.in { opacity: 1; transform: none; }

/* ═══════════ RESPONSIVE ═══════════ */

@media (max-width: 720px) {
  :root { --gutter: 18px; }

  body { font-size: 16px; }

  .site-head {
    padding: calc(10px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  }
  .wordmark {
    font-size: 10.5px;
    letter-spacing: 0.24em;
  }
  .head-actions { gap: 0.7em; }
  .btn-ghost {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  .hero {
    padding-top: clamp(64px, 12vh, 90px);
    padding-bottom: 68px;
  }
  .huge { font-size: clamp(2.55rem, 12.5vw, 3.4rem); }
  .hero-meta {
    line-height: 1.8;
    letter-spacing: 0.1em;
  }

  .section { padding-top: 68px; padding-bottom: 68px; }
  .section-head { margin-bottom: 2.6em; }
  .section-title { font-size: clamp(2.25rem, 11vw, 3.1rem); }

  .grid-tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35em;
  }
  .tab {
    width: 100%;
    padding-inline: 0.5em;
    letter-spacing: 0.12em;
  }
  .grid-legend { gap: 1em 1.5em; line-height: 1.8; }
  .grid-tip {
    max-width: calc(100vw - 24px);
    white-space: normal;
  }

  .rituals { grid-template-columns: 1fr; }
  .ritual { min-height: 168px; }
  .freq-btn { width: 44px; height: 44px; }

  .where-list { grid-template-columns: 1fr; gap: 1em; }
  .screen-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .screen-summary-meta { grid-column: 1 / -1; }
  .where-ctl { gap: 0.6em 1em; }
  .where-ctl .entry-label {
    width: 100%;
    min-width: 0;
    text-align: left;
  }
  .where-ctl input[type="range"] { flex-basis: 100%; }

  .markers li { grid-template-columns: 1fr; gap: 0.5em; }
}

@media (max-width: 480px) {
  .intro-title {
    font-size: clamp(2.2rem, 11vw, 2.85rem);
    overflow-wrap: anywhere;
  }
  .intro-sub { margin-bottom: 2.4em; }
  .entry {
    gap: 1.5em;
    padding: 2em 0;
  }
  .entry-row {
    align-items: stretch;
    gap: 0.65em;
  }
  .entry-row > .entry-label {
    width: 100%;
    min-width: 0;
    text-align: left;
  }
  #dob { width: 100%; min-width: 0; }
  .span-control { width: 100%; gap: 1em; }
  .span-control input[type="range"] { flex: 1; width: auto; min-width: 0; }
  .btn-primary { width: 100%; }
  .entry-note { line-height: 1.7; }

  .tl-sentence { line-height: 1.7; }
}

@media (max-width: 300px) {
  .wordmark {
    font-size: 9.5px;
    letter-spacing: 0.16em;
  }
  .head-actions { gap: 0.45em; }
  .btn-ghost {
    font-size: 9.5px;
    letter-spacing: 0.08em;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .intro { padding-top: 32px; padding-bottom: 32px; }
  .hero { padding-top: 52px; padding-bottom: 52px; }
  .section { padding-top: 56px; padding-bottom: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .io-reveal { animation: none; transition: none; opacity: 1; transform: none; }
  .lifebar-fill, .lifebar-dot { transition: none; }
  .lifebar-dot { animation: none; }
  .pdot { animation-duration: 0.01s; }
}
