/* ===========================================================
   TEMPO — Design System
   Minimalist · Modern · Award-winning
   =========================================================== */

:root {
  /* Palette — warm paper light */
  --bg:        #f4f2ec;
  --surface:   #ffffff;
  --surface-2: #efeee8;
  --ink:       #14110f;
  --muted:     #6d675f;
  --hair:      rgba(20, 17, 15, 0.08);
  --hair-strong: rgba(20, 17, 15, 0.14);
  --accent:    #ec4426;
  --accent-ink:#ffffff;
  --ring-track:rgba(20, 17, 15, 0.08);

  /* Type */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-num: "Inter", ui-sans-serif, system-ui, sans-serif;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.45s;

  /* Layout */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(20,17,15,.04), 0 8px 30px rgba(20,17,15,.06);
  --shadow-lift: 0 2px 6px rgba(20,17,15,.06), 0 24px 60px rgba(20,17,15,.12);
  --maxw: 1120px;
}

:root[data-theme="dark"] {
  --bg:        #0c0b0a;
  --surface:   #161412;
  --surface-2: #1e1b18;
  --ink:       #f3f0ea;
  --muted:     #9a938a;
  --hair:      rgba(243, 240, 234, 0.09);
  --hair-strong: rgba(243, 240, 234, 0.16);
  --accent:    #ff5a3c;
  --accent-ink:#140a06;
  --ring-track:rgba(243, 240, 234, 0.10);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 34px rgba(0,0,0,.5);
  --shadow-lift: 0 2px 8px rgba(0,0,0,.5), 0 30px 70px rgba(0,0,0,.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0c0b0a;
    --surface:   #161412;
    --surface-2: #1e1b18;
    --ink:       #f3f0ea;
    --muted:     #9a938a;
    --hair:      rgba(243, 240, 234, 0.09);
    --hair-strong: rgba(243, 240, 234, 0.16);
    --accent:    #ff5a3c;
    --accent-ink:#140a06;
    --ring-track:rgba(243, 240, 234, 0.10);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 34px rgba(0,0,0,.5);
    --shadow-lift: 0 2px 8px rgba(0,0,0,.5), 0 30px 70px rgba(0,0,0,.6);
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- Header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1.1rem, 4vw, 2.4rem);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--hair);
}

.brand {
  display: inline-flex; align-items: baseline; gap: .06em;
  font-weight: 800; font-size: 1.28rem; letter-spacing: -0.03em;
}
.brand .dot { color: var(--accent); }

.nav { display: flex; align-items: center; gap: .2rem; }
.nav a {
  font-size: .92rem; font-weight: 500; color: var(--muted);
  padding: .5rem .8rem; border-radius: var(--radius-pill);
  transition: color .2s var(--ease), background .2s var(--ease);
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.head-tools { display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: var(--radius-pill);
  border: 1px solid var(--hair-strong); background: var(--surface);
  color: var(--ink); cursor: pointer;
  transition: transform .25s var(--ease), border-color .2s, background .2s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.icon-btn svg { width: 19px; height: 19px; }
.theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: none; }
  :root:not([data-theme="light"]) .theme-moon { display: block; }
}

.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav {
    position: fixed; inset: 68px 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--hair);
    padding: .6rem clamp(1.1rem, 4vw, 2.4rem) 1rem;
    transform: translateY(-140%); transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow);
  }
  .nav.open { transform: translateY(0); }
  .nav a { padding: .85rem .6rem; font-size: 1rem; border-radius: var(--radius-sm); }
  .nav-toggle { display: inline-grid; }
}

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1.1rem, 4vw, 2.4rem); }

.tool-stage {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: clamp(2rem, 6vw, 4.5rem) 0 clamp(1.5rem, 4vw, 3rem);
}

.eyebrow {
  font-size: .8rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .9rem;
}
.tool-stage h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -0.035em;
  line-height: 1.05; margin-bottom: .5rem;
}
.tool-stage .lede { color: var(--muted); max-width: 42ch; font-size: 1.02rem; }

/* ---------- The big display ---------- */
.display {
  font-family: var(--font-num);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv01" 1;
  line-height: 1;
  font-size: clamp(4rem, 19vw, 12.5rem);
  margin: clamp(1.4rem, 4vw, 2.4rem) 0;
  color: var(--ink);
  display: inline-flex; align-items: baseline; justify-content: center;
}
.display .cs, .display .ms { font-size: .42em; color: var(--muted); font-weight: 700; margin-left: .12em; }
.display .sep { animation: none; }
.display.running .blink { animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: .28; } }

/* Progress ring wrapper */
.ring-wrap { position: relative; display: inline-grid; place-items: center; margin: clamp(1rem,3vw,2rem) 0; }
.ring-wrap svg { transform: rotate(-90deg); display: block; }
.ring-track { fill: none; stroke: var(--ring-track); }
.ring-prog  { fill: none; stroke: var(--accent); stroke-linecap: round;
  transition: stroke-dashoffset .3s linear; }
.ring-center {
  position: absolute; inset: 0; display: grid; place-items: center; gap: .2rem;
}
.ring-center .display { margin: 0; font-size: clamp(2.6rem, 11vw, 5.4rem); }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; align-items: center; margin-top: .4rem; }

.btn {
  font-family: inherit; font-size: 1rem; font-weight: 600;
  padding: .95rem 1.9rem; border-radius: var(--radius-pill);
  border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: .55rem;
  transition: transform .22s var(--ease), background .2s, border-color .2s, opacity .2s, box-shadow .25s;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 50%, transparent); }

.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--hair-strong); }
.btn-ghost:hover { transform: translateY(-2px); border-color: var(--accent); }

.btn-quiet { background: transparent; color: var(--muted); padding: .7rem 1rem; }
.btn-quiet:hover { color: var(--ink); }

.btn:disabled { opacity: .4; pointer-events: none; }

/* Preset chips */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 1.4rem 0 .4rem; }
.chip {
  font-family: inherit; font-size: .9rem; font-weight: 600; color: var(--muted);
  padding: .55rem 1.05rem; border-radius: var(--radius-pill);
  border: 1px solid var(--hair-strong); background: var(--surface); cursor: pointer;
  transition: all .2s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--accent); transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Time editor inputs */
.time-input { display: inline-flex; align-items: baseline; gap: .1rem; font-variant-numeric: tabular-nums; }
.time-input input {
  font-family: var(--font-num); font-weight: 800; font-size: clamp(3rem, 12vw, 6rem);
  width: 2.1ch; text-align: center; background: transparent; border: none;
  color: var(--ink); letter-spacing: -0.04em; -moz-appearance: textfield;
  border-bottom: 3px solid transparent; transition: border-color .2s;
}
.time-input input:focus { outline: none; border-bottom-color: var(--accent); }
.time-input input::-webkit-outer-spin-button,
.time-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-input .colon { font-size: clamp(2.4rem, 9vw, 4.6rem); font-weight: 700; color: var(--muted); }

/* Laps */
.laps { width: min(420px, 90vw); margin: 1.8rem auto 0; text-align: left; }
.laps-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem .2rem; border-bottom: 1px solid var(--hair);
  font-variant-numeric: tabular-nums; font-size: .98rem;
  animation: slideIn .35s var(--ease);
}
.laps-row .idx { color: var(--muted); font-weight: 600; }
.laps-row .best { color: var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Cards / grid (home) ---------- */
.hero {
  text-align: center; padding: clamp(3rem, 9vw, 6.5rem) 0 clamp(2rem, 5vw, 3.5rem);
}
.hero h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); font-weight: 800; letter-spacing: -0.045em; line-height: 1.02; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); font-size: clamp(1.05rem, 2.5vw, 1.25rem); max-width: 52ch; margin: 1.1rem auto 0; }

.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem; padding-bottom: clamp(2rem, 6vw, 4rem);
}
.tool-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius); padding: 1.5rem 1.4rem 1.35rem;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s;
  display: flex; flex-direction: column; gap: .55rem; min-height: 168px;
}
.tool-card:hover { transform: translateY(-4px); border-color: var(--hair-strong); box-shadow: var(--shadow-lift); }
.tool-card .ic {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent); margin-bottom: .4rem;
}
.tool-card .ic svg { width: 21px; height: 21px; }
.tool-card h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.tool-card p { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.tool-card .vol { margin-top: auto; font-size: .78rem; font-weight: 600; color: var(--muted); opacity: .8; }
.tool-card::after {
  content: "→"; position: absolute; top: 1.4rem; right: 1.4rem;
  color: var(--muted); opacity: 0; transform: translateX(-4px);
  transition: opacity .3s, transform .3s var(--ease); font-size: 1.1rem;
}
.tool-card:hover::after { opacity: 1; transform: translateX(0); color: var(--accent); }

/* ---------- Content / SEO sections ---------- */
.content { padding: clamp(2rem, 5vw, 3.5rem) 0; border-top: 1px solid var(--hair); }
.content-inner { max-width: 720px; margin: 0 auto; }
.content h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); font-weight: 800; letter-spacing: -0.03em; margin-bottom: 1rem; }
.content h3 { font-size: 1.12rem; font-weight: 700; margin: 1.6rem 0 .5rem; }
.content p { color: var(--muted); margin-bottom: 1rem; }
.content p strong { color: var(--ink); }

.faq details {
  border-bottom: 1px solid var(--hair); padding: 1.1rem 0;
}
.faq summary {
  cursor: pointer; font-weight: 600; font-size: 1.04rem; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.5rem; font-weight: 400; transition: transform .3s var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: .8rem 0 0; }

/* ---------- Ad slots ---------- */
.ad-slot {
  width: 100%; max-width: 728px; margin: 1.6rem auto; min-height: 90px;
  display: grid; place-items: center; border: 1px dashed var(--hair-strong);
  border-radius: var(--radius-sm); color: var(--muted); font-size: .72rem;
  letter-spacing: .12em; text-transform: uppercase; background: var(--surface-2);
}
.ad-slot.rect { max-width: 336px; min-height: 280px; }

/* ---------- Footer ---------- */
.site-foot {
  border-top: 1px solid var(--hair); padding: clamp(2rem, 5vw, 3rem) 0 2.4rem;
  margin-top: 1rem;
}
.foot-grid { display: flex; flex-wrap: wrap; gap: 2.5rem 3.5rem; justify-content: space-between; }
.foot-brand { max-width: 30ch; }
.foot-brand p { color: var(--muted); font-size: .9rem; margin-top: .6rem; }
.foot-col h4 { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .9rem; }
.foot-col a { display: block; color: var(--ink); font-size: .95rem; padding: .28rem 0; opacity: .85; transition: opacity .2s, color .2s; }
.foot-col a:hover { opacity: 1; color: var(--accent); }
.foot-bottom { margin-top: 2.5rem; padding-top: 1.4rem; border-top: 1px solid var(--hair); color: var(--muted); font-size: .84rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }

/* ---------- Toast / status ---------- */
.status { min-height: 1.4rem; color: var(--muted); font-size: .95rem; margin-top: .3rem; }

/* fade-in on load */
.reveal { opacity: 0; transform: translateY(14px); animation: reveal .7s var(--ease) forwards; }
.reveal:nth-child(2){ animation-delay: .05s; }
.reveal:nth-child(3){ animation-delay: .1s; }
@keyframes reveal { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ===========================================================
   MEGA NAV — Apple-style navigation
   =========================================================== */
.site-head { z-index: 80; overflow: visible; }

.mega-nav { display: flex; align-items: center; gap: .1rem; }
.mega-trigger, .mega-link {
  font-family: inherit; font-size: .94rem; font-weight: 500; color: var(--muted);
  background: transparent; border: none; cursor: pointer;
  padding: .55rem .85rem; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: .32rem; white-space: nowrap;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.mega-trigger .chev { width: 12px; height: 12px; opacity: .55; transition: transform .35s var(--ease); }
.mega-trigger:hover, .mega-link:hover,
.mega-trigger.active, .mega-trigger[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }
.mega-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

.mega-panel-wrap { position: absolute; top: 100%; left: 0; right: 0; pointer-events: none; }
.mega-panel {
  position: absolute; top: 6px; left: clamp(1.1rem,4vw,2.4rem); right: clamp(1.1rem,4vw,2.4rem);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.7) blur(22px); -webkit-backdrop-filter: saturate(1.7) blur(22px);
  border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-lift);
  padding: 1.5rem;
  opacity: 0; transform: translateY(-12px) scale(.99); visibility: hidden; pointer-events: none;
  transition: opacity .32s var(--ease), transform .32s var(--ease), visibility .32s;
}
.mega-panel.open { opacity: 1; transform: translateY(0) scale(1); visibility: visible; pointer-events: auto; }
.mega-inner { max-width: var(--maxw); margin: 0 auto; }
.mega-cat { display: none; }
.mega-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px,1fr)); gap: .25rem; }
.mega-item { display: flex; align-items: center; gap: .85rem; padding: .7rem .8rem; border-radius: var(--radius-sm);
  transition: background .2s var(--ease); }
.mega-item:hover { background: var(--surface-2); }
.mega-item .mi-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent); flex: none; transition: background .2s, color .2s, transform .2s var(--ease); }
.mega-item:hover .mi-ic { background: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.mega-item .mi-ic svg { width: 20px; height: 20px; }
.mega-item .mi-tx { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.mega-item .mi-tx b { font-size: .95rem; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.mega-item .mi-tx em { font-style: normal; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mega-item.current { background: var(--surface-2); }
.mega-item.current .mi-ic { background: var(--accent); color: var(--accent-ink); }
.mega-sub { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--hair); font-size: .86rem; color: var(--muted); font-weight: 500; }
.mega-sub a { color: var(--ink); font-weight: 600; padding: 0 .12rem; transition: color .2s; }
.mega-sub a:hover { color: var(--accent); }

.mega-scrim { position: fixed; inset: 0; background: rgba(10,9,8,.30); opacity: 0; pointer-events: none;
  transition: opacity .32s var(--ease); z-index: -1; }
body.mega-open .mega-scrim { opacity: 1; pointer-events: auto; }

/* Mobile drawer */
@media (max-width: 860px) {
  .mega-nav { display: none; }
  .mega-panel-wrap { position: fixed; inset: 0; top: 0; overflow-y: auto; background: var(--bg);
    transform: translateY(-102%); transition: transform .5s var(--ease); pointer-events: auto; z-index: 70;
    padding: 82px clamp(1.1rem,5vw,2rem) 3rem; }
  .mega-panel-wrap.mobile-open { transform: translateY(0); }
  .mega-panel { position: static; opacity: 1; transform: none; visibility: visible; pointer-events: auto;
    background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; border: none; box-shadow: none;
    padding: .8rem 0; margin: 0; border-radius: 0; border-bottom: 1px solid var(--hair); }
  .mega-panel:last-child { border-bottom: none; }
  .mega-cat { display: block; font-size: .76rem; letter-spacing: .14em; text-transform: uppercase;
    color: var(--muted); font-weight: 700; margin-bottom: .5rem; }
  .mega-grid { grid-template-columns: 1fr; gap: 0; }
  .mega-item { padding: .8rem .4rem; }
}
