/* ============================================================
   tbasak.xyz - shared design tokens and page chrome
   Visual language follows the VirgOS brand system:
   Satoshi display / Geist body, coastal palette,
   one saturated accent per viewport.
   ============================================================ */

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

:root {
  /* coastal palette (shader stops - used for the hero mesh only) */
  --c-teal:   #72b9bb;
  --c-green:  #8cc5b8;
  --c-aqua:   #b5d9d9;
  --c-citrus: #dbf4a4;
  --c-peach:  #ffd1bd;
  --c-shell:  #ffebe0;

  /* light theme */
  --bg:        #fbfaf8;
  --surface:   #ffffff;
  --ink:       #14181a;
  --ink-muted: #545d61;
  --ink-faint: #8a9296;
  --line:      #e4e2dd;
  --line-soft: #eeece7;
  --accent:    #2f6f6f;
  --accent-on: #ffffff;

  /* shape system: containers 14px, controls pill, hairlines 0 */
  --r-surface: 14px;
  --r-control: 999px;

  --shadow: 0 1px 2px rgba(20, 24, 26, .04), 0 12px 32px -12px rgba(47, 111, 111, .16);

  --font-display: 'Satoshi', 'Geist', system-ui, sans-serif;
  --font-body: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --gutter: clamp(1.25rem, 5vw, 4rem);
  --measure: 62ch;

  /* z-index scale */
  --z-grain: 60;
  --z-header: 50;
  --z-hero-copy: 2;
}

:root[data-theme="dark"],
html.dark {
  --bg:        #0c1011;
  --surface:   #141a1c;
  --ink:       #eef1f0;
  --ink-muted: #a3adb0;
  --ink-faint: #6d7679;
  --line:      #232b2d;
  --line-soft: #1b2224;
  --accent:    #ffd1bd;   /* #2f6f6f fails AA on near-black; the brand swap */
  --accent-on: #10171a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -16px rgba(0, 0, 0, .6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0c1011;
    --surface:   #141a1c;
    --ink:       #eef1f0;
    --ink-muted: #a3adb0;
    --ink-faint: #6d7679;
    --line:      #232b2d;
    --line-soft: #1b2224;
    --accent:    #ffd1bd;
    --accent-on: #10171a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -16px rgba(0, 0, 0, .6);
  }
}

html { scroll-behavior: smooth; scroll-padding-top: 6rem; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a { color: inherit; }

:where(a, button, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- type ---------- */

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.04;
  text-wrap: balance;
}

h2 { font-size: clamp(1.9rem, 4.2vw, 3.1rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.45rem); font-weight: 700; letter-spacing: -0.02em; }

p { text-wrap: pretty; }

.lede { font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--ink-muted); max-width: var(--measure); }
.body { color: var(--ink-muted); max-width: var(--measure); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }

/* ---------- layout ---------- */

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--gutter); }

section { padding-block: clamp(4.5rem, 10vw, 8.5rem); }
.rule { border-top: 1px solid var(--line-soft); }

/* ---------- header ---------- */

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-on);
  padding: .75rem 1.25rem; border-radius: 0 0 var(--r-surface) 0;
  font-size: .85rem; font-weight: 600; z-index: 100;
}
.skip:focus { left: 0; }

.site-header {
  position: sticky; top: 0; z-index: var(--z-header);
  height: 68px; display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease;
}
.site-header.is-stuck { border-bottom-color: var(--line-soft); }

.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }

.wordmark {
  font-family: var(--font-display); font-weight: 900; font-size: 1.05rem;
  letter-spacing: -0.02em; text-decoration: none; white-space: nowrap;
}
.wordmark i { font-style: normal; color: var(--accent); }

.site-nav { display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2rem); }
.site-nav a {
  font-size: .875rem; color: var(--ink-muted); text-decoration: none;
  white-space: nowrap; transition: color .2s ease;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }

.theme-toggle {
  appearance: none; background: transparent; border: 1px solid var(--line);
  color: var(--ink-muted); width: 34px; height: 34px; border-radius: var(--r-control);
  display: grid; place-items: center; cursor: pointer; font-size: .8rem;
  transition: border-color .2s ease, color .2s ease, transform .12s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-faint); }
.theme-toggle:active { transform: scale(.94); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  padding: .8rem 1.5rem; border-radius: var(--r-control);
  text-decoration: none; white-space: nowrap; border: 1px solid transparent;
  transition: background-color .22s ease, color .22s ease, border-color .22s ease, transform .12s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-faint); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.btn:active { transform: translateY(1px); }

.link-arrow {
  display: inline-flex; align-items: center; gap: .45rem;
  font-weight: 500; font-size: .9rem; color: var(--ink);
  text-decoration: none; border-bottom: 1px solid var(--line);
  padding-bottom: 2px; transition: border-color .22s ease, color .22s ease;
}
.link-arrow span { transition: transform .22s cubic-bezier(.16,1,.3,1); }
.link-arrow:hover { color: var(--accent); border-bottom-color: var(--accent); }
.link-arrow:hover span { transform: translateX(4px); }

/* ---------- tags ---------- */

.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .01em;
  color: var(--ink-muted); background: color-mix(in srgb, var(--ink) 4%, transparent);
  padding: .25rem .6rem; border-radius: 6px; white-space: nowrap;
}

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--line-soft); padding-block: 2.5rem 3rem; }
.site-footer .wrap {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem;
  align-items: center; justify-content: space-between;
}
.site-footer a { color: var(--ink-muted); text-decoration: none; font-size: .875rem; }
.site-footer a:hover { color: var(--ink); }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.5rem; }

/* ---------- grain (fixed, never on a scrolling container) ---------- */

.grain {
  position: fixed; inset: 0; z-index: var(--z-grain); pointer-events: none;
  opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .grain, html.dark .grain { mix-blend-mode: screen; opacity: .05; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .grain { mix-blend-mode: screen; opacity: .05; }
}

/* ---------- scroll reveal ---------- */

.reveal { opacity: 0; transform: translateY(20px); }
.reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1);
  transition-delay: var(--d, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
