/* ---------- fonts ---------- */
@font-face {
  font-family: "Open Runde";
  src: url("fonts/OpenRunde-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Open Runde";
  src: url("fonts/OpenRunde-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #000000;
  --muted: #808080;
  --chip: #e5e5e5;
  --chip-hover: #dbdbdb;
  --accent: #f45b48;
  --shadow-front: 0 8px 32px rgba(0, 0, 0, .23);
  --shadow-back: 0 1px 4px rgba(0, 0, 0, .35);

  /* motion */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --spring: cubic-bezier(.23, 1, .32, 1); /* fallback when linear() is unsupported */
  --spring-dur: 450ms;
  --fan-x: 262px;
  --back-w: 324px;
  --back-h: 296px;
}

/* Apple-style spring: duration .55s, bounce .25 (2.8% overshoot), sampled at 60fps */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.01647, 0.05977, 0.1219, 0.1962, 0.2773, 0.3609, 0.4439, 0.5238, 0.5987, 0.6677, 0.73, 0.7853, 0.8336, 0.8751, 0.9103, 0.9395, 0.9634, 0.9825, 0.9974, 1.009, 1.017, 1.023, 1.026, 1.028, 1.028, 1.028, 1.027, 1.025, 1.023, 1.02, 1.018, 1.016, 1.013, 1.011, 1.009, 1.008, 1.006, 1.005, 1.003, 1.002, 1.002, 1.001, 1);
    --spring-dur: 717ms;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1a;
  --fg: #ededed;
  --chip: #2e2e2e;
  --chip-hover: #3a3a3a;
  --shadow-front: 0 12px 40px rgba(0, 0, 0, .6);
  --shadow-back: 0 2px 8px rgba(0, 0, 0, .5);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: clip;
  font: 400 24px/1 "Open Runde", -apple-system, system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  zoom: .7; /* the design is drawn at 1920 wide; one knob scales the whole page */
  transition: background-color 200ms ease, color 200ms ease;
}

button {
  font: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
::selection { background: var(--accent); color: #fff; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- header ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 28px 24px;
}
.right { justify-self: end; display: flex; align-items: center; gap: 22px; }

/* copy email */
.copy {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  transition: transform 160ms var(--ease-out);
}
.copy:active { transform: scale(.98); }
.copy__icons {
  position: relative;
  width: 24px; height: 24px;
  color: var(--muted);
  transition: color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .copy:hover .copy__icons { color: var(--fg); }
}
.copy__icons svg {
  position: absolute; inset: 0;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), filter 200ms var(--ease-out);
}
.i-check { opacity: 0; transform: scale(.8); filter: blur(2px); }
.i-check path { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset 250ms var(--ease-out); }
.copy.is-copied .copy__icons { color: var(--fg); }
.copy.is-copied .i-copy { opacity: 0; transform: scale(.8); filter: blur(2px); }
.copy.is-copied .i-check { opacity: 1; transform: none; filter: none; }
.copy.is-copied .i-check path { stroke-dashoffset: 0; transition-delay: 60ms; }

/* theme toggle */
.theme {
  position: relative;
  width: 24px; height: 24px;
  color: var(--accent);
  transition: transform 160ms var(--ease-out);
}
.theme:active { transform: scale(.9); }
.theme svg {
  position: absolute; inset: 0;
  transition: opacity 200ms var(--ease-out), transform 300ms var(--ease-out);
}
.i-sun { opacity: 0; transform: rotate(-90deg) scale(.7); }
[data-theme="dark"] .i-moon { opacity: 0; transform: rotate(90deg) scale(.7); }
[data-theme="dark"] .i-sun { opacity: 1; transform: none; }

/* clock */
.clock { font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock__digits span { display: inline-block; white-space: pre; }

/* ---------- hero ---------- */
main { padding: 118px 24px 80px; }
.hero { max-width: 1048px; margin: 0 auto; }

/* photo stack */
.stack {
  --open: 0;
  position: relative;
  display: block;
  width: 241px; height: 332px;
  border-radius: 20px;
}
.card {
  position: absolute;
  display: block;
  border-radius: 20px;
  transition: transform 350ms var(--ease-out);
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: var(--shadow);
  opacity: var(--open);
  transition: opacity 300ms var(--ease-out);
}
.card img {
  position: relative;
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.card--front {
  inset: 0;
  z-index: 1;
  --shadow: var(--shadow-front);
  transform: rotate(calc(var(--open) * -3.5deg)) scale(calc(1 + var(--open) * .07));
}
.card--back {
  width: var(--back-w); height: var(--back-h);
  left: 50%; top: 50%;
  margin: calc(var(--back-h) / -2) 0 0 calc(var(--back-w) / -2);
  --shadow: var(--shadow-back);
  transform: translateX(calc(var(--open) * var(--fan-x))) rotate(calc(var(--open) * 4deg)) scale(calc(.7 + var(--open) * .3));
}

/* open: spring in, back card trails the front by 50ms. close: snappy ease-out, no stagger */
.stack.is-open { --open: 1; }
@media (hover: hover) and (pointer: fine) {
  .stack:hover { --open: 1; }
  .stack:hover .card { transition: transform var(--spring-dur) var(--spring); }
  .stack:hover .card--back { transition-delay: 50ms; }
}
.stack.is-open .card { transition: transform var(--spring-dur) var(--spring); }
.stack.is-open .card--back { transition-delay: 50ms; }

/* intro */
.intro {
  margin-top: 46px;
  font-weight: 500;
  font-size: 48px;
  line-height: 58px;
}
.intro h1 { display: flex; align-items: center; gap: 20px; margin: 0; font: inherit; }
.intro p { margin: 0; }

/* pronounce button */
.say {
  flex: none;
  display: grid; place-items: center;
  width: 55px; height: 55px;
  border-radius: 14px;
  background: var(--chip);
  color: #818181;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease;
}
.say:active { transform: scale(.95); }
@media (hover: hover) and (pointer: fine) {
  .say:hover { background: var(--chip-hover); }
}
.say.is-playing { color: var(--fg); }
.say.is-playing .w1 { animation: wave 1s ease-in-out infinite; }
.say.is-playing .w2 { animation: wave 1s ease-in-out infinite 180ms; }
@keyframes wave {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  :root { --fan-x: 140px; --back-w: 230px; --back-h: 210px; }
  body { font-size: 18px; zoom: 1; }
  .top { grid-template-columns: 1fr auto; padding: 20px; row-gap: 16px; }
  .right { grid-row: 1; grid-column: 2; }
  .copy { grid-row: 2; grid-column: 1 / -1; justify-self: start; gap: 12px; }
  .stack { width: 200px; height: 276px; }
  .copy__icons { width: 20px; height: 20px; }
  .copy__icons svg { width: 20px; height: 20px; }
  .right { gap: 14px; }
  .theme, .theme svg { width: 20px; height: 20px; }
  main { padding: 24px 20px 64px; }
  .intro { margin-top: 32px; font-size: 30px; line-height: 38px; }
  .intro h1 { gap: 14px; }
  .say { width: 40px; height: 40px; border-radius: 10px; }
  .say svg { width: 26px; height: 26px; }
}

/* ---------- reduced motion: keep fades, drop movement ---------- */
@media (prefers-reduced-motion: reduce) {
  .card, .stack:hover .card, .stack.is-open .card { transition-duration: 0ms; transition-delay: 0ms; }
  .theme svg, .copy__icons svg { transition-property: opacity; }
  .say.is-playing .w1, .say.is-playing .w2 { animation: none; }
}
