/* ---------- Fonts ---------- */
@font-face {
  font-family: "Signifier";
  src: url("fonts/signifier-regular-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #fdfdfd;
  --ink: #211e1d;
  --primary: #3653E1;
  --primary-muted: rgba(54, 83, 225, 0.7);

  /* Grid: 12 columns + an 8px vertical baseline. Margins, gutter and the
     vertical metrics step down by breakpoint. Every value is a multiple of 8. */
  --margin: 80px;        /* page side margin */
  --gutter: 24px;        /* column gutter */
  --pad-top: 40px;       /* baseline offset from the top */
  --pad-bottom: 88px;    /* baseline offset from the bottom */
  --bio-lift: 376px;     /* how far the bio sits above the footer row */
  --stage-gap: 16px;     /* gap between the headline and the date/weather row */

  --font-ui: "Inter", system-ui, sans-serif;
  --font-display: "Signifier", Georgia, serif;
}

/* Dark mode: the palette simply inverts. */
:root[data-theme="dark"] {
  --bg: #211e1d;
  --ink: #fdfdfd;
  --primary: #6892f2;
  --primary-muted: rgba(104, 146, 242, 0.9);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 500 14px/1.2 var(--font-ui);
  letter-spacing: -0.035em;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.bio p {
  user-select: text;
}

.bio p::selection {
  background: var(--ink);
  color: var(--bg);
}

/* Water-ripple canvas: fixed behind the content, never intercepts pointer
   events. Falls back to the body background if ripple.js doesn't run. */
#ripple {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ---------- Grid layout ----------
   12 columns horizontally, three rows vertically (header / stage / footer).
   The header sits on the top row; the bio and headline live in the flexible
   middle row, both bottom-anchored, so the bio + headline + footer read as a
   cluster hugging the bottom that rides up as the window gets shorter.
   All vertical offsets are 8px multiples — the baseline grid. */
.page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: auto 1fr auto;
  column-gap: var(--gutter);
  padding: var(--pad-top) var(--margin) var(--pad-bottom);
}

.name { grid-area: 1 / 1 / 2 / 7; align-self: center; }
.nav  { grid-area: 1 / 7 / 2 / 13; justify-self: end; display: flex; align-items: center; gap: 20px; }
.nav a { padding: 12px 8px; }
.nav a span { transition: color 0.15s; }
.nav a:hover span { color: var(--primary); }

/* Bio: right columns (inset one column from the right margin), bottom-anchored
   a fixed distance above the footer. */
.bio {
  grid-area: 2 / 6 / 3 / 12;
  justify-self: end;
  align-self: end;
  margin-bottom: var(--bio-lift);
  width: min(321px, 100%);
}

/* Headline: spans the full width, bottom-anchored just above the footer.
   Fluid with viewport width (~68.6% of it): 240px@1440, 160px@967. */
.headline {
  grid-area: 2 / 1 / 3 / 13;
  align-self: end;
  margin-bottom: var(--stage-gap);
  font: 400 clamp(110px, 16.6vw, 280px)/0.9 var(--font-display);
  font-style: italic;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Footer: date · place · weather · theme toggle. Bottom row, under the headline. */
.meta {
  grid-area: 3 / 1 / 4 / 13;
  align-self: end;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 400px;
  max-width: 100%;
}

#clock{
  font-variant-numeric: tabular-nums;
}

/* Light/dark toggle: sun + moon, the active mode underlined. */
.theme { display: flex; align-items: center; gap: 20px; }
.theme-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  transition: color 0.15s;
}
/* Hit zone: 44×44px. Gap 20px – 14px overlap on each side = 8px overlap zone between the two buttons. */
.theme-btn::before {
  content: '';
  position: absolute;
  inset: -11px -14px;
}

/* Active button: icon + underline in primary blue. */
:root[data-theme="light"] .theme-btn[data-set="light"],
:root[data-theme="dark"]  .theme-btn[data-set="dark"]  { color: var(--primary); }

/* Inactive button hover: primary at 70% opacity. */
:root[data-theme="light"] .theme-btn[data-set="dark"]:hover,
:root[data-theme="dark"]  .theme-btn[data-set="light"]:hover { color: var(--primary-muted); }
.theme-btn svg { display: block; }
/* Active mode → filled icon; the other → outline. (The active one is also
   underlined below.) */
.theme-btn .i-fill, .theme-btn .i-outline { display: none; }
:root[data-theme="light"] .theme-btn[data-set="light"] .i-fill,
:root[data-theme="dark"]  .theme-btn[data-set="dark"]  .i-fill,
:root[data-theme="light"] .theme-btn[data-set="dark"]  .i-outline,
:root[data-theme="dark"]  .theme-btn[data-set="light"] .i-outline { display: block; }

.theme-btn::after {
  content: "";
  width: 16px;
  height: 1px;
  background: currentColor;
  opacity: 0;            /* reserves space so icons never shift */
}
:root[data-theme="light"] .theme-btn[data-set="light"]::after,
:root[data-theme="dark"]  .theme-btn[data-set="dark"]::after { opacity: 1; }

/* ---------- Width breakpoints: margins + gutter step down ----------
   (80px holds down to the small desktop sizes, matching the Figma frames.) */
@media (max-width: 899px) { :root { --margin: 56px; --gutter: 16px; } }
@media (max-width: 699px) { :root { --margin: 32px; --gutter: 8px; --pad-bottom: 64px; } }

/* ---------- Height breakpoints: compress the vertical metrics so the
   cluster keeps hugging the bottom on short windows. ---------- */
@media (max-height: 860px) { :root { --pad-bottom: 72px; } }
@media (max-height: 600px) { :root { --bio-lift: 192px; --pad-top: 32px; --pad-bottom: 48px; } }

/* ---------- Phones: single column, no avatar ---------- */
@media (max-width: 540px) {
  :root { --margin: 16px; }
  .page {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 24px var(--margin) 32px;
  }
  .name, .nav, .bio, .headline, .meta { grid-area: auto; }

  /* Toggle moves to the top-right, across from the name. */
  .theme { position: absolute; top: 22px; right: var(--margin); }

  .name     { order: 1; align-self: stretch; }
  .headline { order: 2; align-self: auto; white-space: normal;
              margin: 40px 0 0; font-size: clamp(96px, 36vw, 150px); line-height: 0.85; }
  .bio      { order: 3; align-self: auto; margin: 24px 0 0; width: auto; }
  .nav      { order: 4; flex-direction: column; align-items: flex-start; gap: 0; margin-top: 64px; }
  .nav a    { padding-inline: 0; font-size: 20px; }
  .meta     { order: 5; align-self: auto; width: 100%; margin-top: auto; }
}
