/* ==========================================================================
   DUKE KAMANDA — theme.css
   Color tokens, typography scale, light/dark variables, grain overlay,
   theme-toggle icon logic.
   Neumorphic / soft-UI system: monochrome-leaning surfaces, dual-tone
   soft shadows (raised + inset), generous radii. Brand hues unchanged:
   #FFAE00 / #B40000 / #7C3AED / #00BFA6 — now expressed as soft glows
   and pressed-accent states rather than hard fills.
   Gontserrat = everything; Shadows Into Light = accent words only
   ========================================================================== */

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

/* ── Self-hosted brand font ──────────────────────────────────────────
   Gontserrat is used across the entire site (display, UI, labels). */
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-SemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gontserrat'; src: url('fonts/Gontserrat-BoldItalic.ttf') format('truetype'); font-weight: 700; font-style: italic; font-display: swap; }

/* Display + accent face. Shadows Into Light = headings and the gold accent
   words inside them. Body/UI stay on Gontserrat. */
@font-face { font-family: 'Shadows Into Light'; src: url('fonts/ShadowsIntoLight-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }

/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --ink: #17181b;
  --paper: #EDEAE2;

  /* Brand hues — fixed regardless of theme */
  --amber: #FFAE00;
  --crimson: #B40000;
  --violet: #7C3AED;
  --teal: #00BFA6;

  /* Dark theme (default): soft charcoal base so dual-tone shadows read.
     Amber still clears AA/AAA for small text on this surface. */
  --accent: var(--amber);
  --accent-2: var(--teal);
  --on-accent: var(--ink);
  --on-accent-muted: rgba(23, 24, 27, 0.75);
  --accent-border: rgba(255, 174, 0, 0.4);
  --accent-dim: rgba(255, 174, 0, 0.12);
  --scrim: rgba(20, 21, 24, 0.62);
  --accent-scrim: rgba(255, 174, 0, 0.72);

  --bg: #1C1D21;
  --bg-raised: #202126;
  --bg-sunken: #191A1D;
  --fg: var(--paper);
  --fg-muted: rgba(237, 234, 226, 0.62);
  --fg-faint: rgba(237, 234, 226, 0.22);
  --rule: rgba(237, 234, 226, 0.1);
  --rule-soft: rgba(237, 234, 226, 0.06);
  --card-border: rgba(237, 234, 226, 0.06);
  --nav-bg: rgba(28, 29, 33, 0.92);

  /* Neumorphic dual-shadow "material" system — validated on the homepage
     prototype (37ddcad), now the site-wide default. Surfaces sit at
     --bg-raised, the same family as the page background, so depth reads
     from the light/dark shadow pair rather than a border or contrasting
     fill. Light source assumed top-left: "hi" shadow top-left, "lo"
     shadow bottom-right. */
  --neu-hi: rgba(255, 255, 255, 0.05);
  --neu-lo: rgba(0, 0, 0, 0.55);
  /* wide, low-alpha companion tone — stacked under the contact shadow so
     the glow keeps dissolving well past where the tight shadow ends,
     instead of stopping at a visible rectangular edge. */
  --neu-hi-soft: rgba(255, 255, 255, 0.025);
  --neu-lo-soft: rgba(0, 0, 0, 0.26);

  /* Each raised shadow layers a tight "contact" shadow (defines the lift)
     with a much wider, much softer "ambient" shadow (lets it dissolve to
     0% opacity gradually rather than reading as a boxed halo). */
  --neu-raised-sm: -3px -3px 8px var(--neu-hi), 3px 3px 8px var(--neu-lo), -2px -2px 22px var(--neu-hi-soft), 2px 2px 22px var(--neu-lo-soft);
  --neu-raised-md: -6px -6px 16px var(--neu-hi), 6px 6px 16px var(--neu-lo), -4px -4px 46px var(--neu-hi-soft), 4px 4px 46px var(--neu-lo-soft);
  --neu-raised-lg: -9px -9px 24px var(--neu-hi), 9px 9px 24px var(--neu-lo), -6px -6px 68px var(--neu-hi-soft), 6px 6px 68px var(--neu-lo-soft);
  --neu-pressed-sm: inset -3px -3px 6px var(--neu-hi), inset 3px 3px 6px var(--neu-lo);
  --neu-pressed-md: inset -5px -5px 12px var(--neu-hi), inset 5px 5px 12px var(--neu-lo);
  --neu-pressed-lg: inset -8px -8px 20px var(--neu-hi), inset 8px 8px 20px var(--neu-lo);

  --neu-text-emboss: -1px -1px 1px var(--neu-lo), 1px 1px 1px var(--neu-hi);
  --neu-text-engrave: 1px 1px 1px var(--neu-hi), -1px -1px 1px var(--neu-lo);

  /* filter equivalents of the raised shadows — for surfaces that also need
     overflow: hidden to clip their own content (media zoom, header strips).
     box-shadow is clipped by an element's own overflow; filter is not,
     since it composites after the element (and its clipping) is rendered.
     This keeps the shadow fading smoothly to 0% instead of hard-cutting
     at the box edge. */
  --neu-raised-sm-filter: drop-shadow(-3px -3px 8px var(--neu-hi)) drop-shadow(3px 3px 8px var(--neu-lo)) drop-shadow(-2px -2px 22px var(--neu-hi-soft)) drop-shadow(2px 2px 22px var(--neu-lo-soft));
  --neu-raised-md-filter: drop-shadow(-6px -6px 16px var(--neu-hi)) drop-shadow(6px 6px 16px var(--neu-lo)) drop-shadow(-4px -4px 46px var(--neu-hi-soft)) drop-shadow(4px 4px 46px var(--neu-lo-soft));
  --neu-raised-lg-filter: drop-shadow(-9px -9px 24px var(--neu-hi)) drop-shadow(9px 9px 24px var(--neu-lo)) drop-shadow(-6px -6px 68px var(--neu-hi-soft)) drop-shadow(6px 6px 68px var(--neu-lo-soft));

  --orb-1: rgba(255, 174, 0, 0.16);
  --orb-2: rgba(124, 58, 237, 0.13);
  --orb-3: rgba(180, 0, 0, 0.13);
  --orb-4: rgba(0, 191, 166, 0.11);
  --orb-blend: screen;

  --serif: 'Gontserrat', sans-serif;                  /* display / headings */
  --accent-font: 'Shadows Into Light', cursive;       /* accent words only */
  --sans: 'Gontserrat', sans-serif;                   /* body / UI */
  --mono: 'Gontserrat', sans-serif;                   /* labels */

  /* Motion — the de-facto curves already used across the theme, tokenized
     so they can't drift. --ease-out for entrances/reveals; --ease-in-out
     for on-screen movement. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* Type scale */
  --fs-hero: clamp(4rem, 10vw, 11rem);
  --fs-display: clamp(3rem, 7vw, 7rem);
  --fs-h2: clamp(2rem, 4.5vw, 4rem);
  --fs-h3: clamp(1.6rem, 3vw, 2.6rem);
  --fs-h4: 1.25rem;
  --fs-body: 16px;
  --fs-small: 13px;
  --fs-label: 10px;
  --fs-micro: 9px;

  --pad-x: 2.5rem;
  --pad-section: 5rem;

  --grain-opacity: 0.04;

  /* Neumorphic radii */
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --radius-pill: 999px;
}

[data-theme="light"] {
  /* Light theme: warm soft-gray base, same principle flipped. Crimson/violet
     clear AA on this surface. */
  --accent: var(--crimson);
  --accent-2: var(--violet);
  --on-accent: var(--paper);
  --on-accent-muted: rgba(237, 234, 226, 0.88);
  --accent-border: rgba(180, 0, 0, 0.35);
  --accent-dim: rgba(180, 0, 0, 0.08);
  --scrim: rgba(233, 229, 219, 0.64);
  --accent-scrim: rgba(180, 0, 0, 0.72);

  --bg: #E7E3D9;
  --bg-raised: #ECE8DE;
  --bg-sunken: #DFDBCF;
  --fg: var(--ink);
  --fg-muted: rgba(23, 24, 27, 0.62);
  --fg-faint: rgba(23, 24, 27, 0.32);
  --rule: rgba(23, 24, 27, 0.12);
  --rule-soft: rgba(23, 24, 27, 0.07);
  --card-border: rgba(23, 24, 27, 0.07);
  --nav-bg: rgba(231, 227, 217, 0.92);

  --neu-hi: rgba(255, 255, 255, 0.85);
  --neu-lo: rgba(20, 16, 8, 0.14);
  --neu-hi-soft: rgba(255, 255, 255, 0.4);
  --neu-lo-soft: rgba(20, 16, 8, 0.07);

  --orb-1: rgba(180, 0, 0, 0.09);
  --orb-2: rgba(124, 58, 237, 0.07);
  --orb-3: rgba(255, 174, 0, 0.1);
  --orb-4: rgba(0, 191, 166, 0.06);
  --orb-blend: multiply;

  --grain-opacity: 0.03;
}

/* ── Neumorphic shadow primitives ──────────────────────────────────────
   .neu-raised-sm/md/lg   embossed surface, resting state
   .neu-pressed-sm/md/lg  pressed / recessed surface
   .neu-flat               shallow ambient shadow for full-width bars
   ─────────────────────────────────────────────────────────────────────── */
.neu-raised-sm  { box-shadow: var(--neu-raised-sm); }
.neu-raised-md  { box-shadow: var(--neu-raised-md); }
.neu-raised-lg  { box-shadow: var(--neu-raised-lg); }
.neu-pressed-sm { box-shadow: var(--neu-pressed-sm); }
.neu-pressed-md { box-shadow: var(--neu-pressed-md); }
.neu-pressed-lg { box-shadow: var(--neu-pressed-lg); }
.neu-flat {
  box-shadow: 0 8px 22px var(--neu-lo);
}

/* ── Base ───────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}

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

img { max-width: 100%; display: block; }
a { color: inherit; }

/* ── Background orb canvas ──────────────────────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

#bg-canvas .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  mix-blend-mode: var(--orb-blend);
  will-change: transform;
  transition: background-color 0.6s ease;
}

/* ── Grain overlay ──────────────────────────────────────────────────── */
.grain-overlay {
  position: fixed;
  inset: -100%;
  z-index: 999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(6) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -2%); }
  80%  { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* ── Typography helpers ─────────────────────────────────────────────── */
.t-serif { font-family: var(--serif); }
.t-mono {
  font-family: var(--mono);
  font-size: var(--fs-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1; letter-spacing: -0.02em; }

.sec-label {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.sec-label::after { content: ''; flex: 1; height: 1px; background: var(--neu-lo); }

/* ── Page width ─────────────────────────────────────────────────────── */
:root { --page-max: 1600px; }
body > nav,
body > section,
body > footer,
body > .marquee-wrap,
body > .phil {
  max-width: var(--page-max);
  margin-left: auto;
  margin-right: auto;
}

/* ── Nav ────────────────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0.9rem; left: 0.9rem; right: 0.9rem;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 22px var(--neu-lo);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}

.logo {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
}
/* Full name on wide screens; abbreviate to "Duke K." once the nav gets
   tight enough that it would collide with the menu links. */
.logo-abbr { display: none; }
@media (max-width: 900px) {
  .logo-full { display: none; }
  .logo-abbr { display: inline; }
}

.nav-links { display: flex; gap: 1.85rem; list-style: none; align-items: center; }
.nav-links a {
  font-family: var(--mono);
  font-size: var(--fs-label);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--fg); }

/* ── Theme toggle ───────────────────────────────────────────────────── */
.theme-toggle {
  background: var(--bg-raised);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  box-shadow: var(--neu-raised-sm);
  transition: color 0.25s, box-shadow 0.25s ease, transform 0.25s;
}
.theme-toggle:hover { color: var(--accent); box-shadow: var(--neu-pressed-sm); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 15px; height: 15px; }

/* icon swap: show moon on dark, sun on light */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── Layout primitives ──────────────────────────────────────────────── */
section { padding: var(--pad-section) var(--pad-x); position: relative; }
.page-top {
  padding-top: 9rem;
  background-image: linear-gradient(var(--scrim), var(--scrim)), url('media/abstract/mesh-work.svg');
  background-size: cover;
  background-position: center;
}

.divider { height: 1px; background: var(--rule); border: none; border-radius: 1px; }

/* ── Buttons / links ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: var(--fs-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.95rem 1.75rem;
  position: relative;
  background: var(--bg-raised);
  box-shadow: var(--neu-raised-sm);
  transition: color 0.3s, box-shadow 0.2s ease, transform 0.15s ease;
}
.btn:hover { color: var(--accent); box-shadow: var(--neu-pressed-sm); }
.btn:active { transform: scale(0.98); }
.btn.solid {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: var(--neu-raised-sm);
}
.btn.solid:hover { color: var(--on-accent); box-shadow: var(--neu-pressed-sm); }

/* ── Footer ─────────────────────────────────────────────────────────── */
footer {
  margin: 1.5rem 0.9rem 1.25rem;
  padding: 1.25rem 1.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  box-shadow: 0 -1px 0 var(--neu-lo);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.ft {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.ft a { color: inherit; text-decoration: none; }
.ft a:hover { color: var(--accent); }

/* ── Skip-to-top floating button ────────────────────────────────────── */
.skip-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 210;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--fg-muted);
  box-shadow: var(--neu-raised-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease,
              box-shadow 0.25s ease, color 0.25s ease;
}
.skip-top.visible { opacity: 1; visibility: visible; transform: none; }
.skip-top:hover { color: var(--accent); box-shadow: var(--neu-pressed-sm); }
.skip-top:active { transform: scale(0.94); }
.skip-top svg { width: 18px; height: 18px; }
@media (max-width: 640px) {
  .skip-top { bottom: 1rem; right: 1rem; width: 42px; height: 42px; }
}

/* ── Metric placeholder flag (house rule: never invent numbers) ─────── */
.metric-pending {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  box-shadow: var(--neu-pressed-sm);
}

/* ── Responsive base ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --pad-x: 1.25rem; --pad-section: 3.5rem; }
  nav { padding: 0.75rem 1.1rem; border-radius: var(--radius-md); }
  .nav-links { gap: 1.1rem; }
  .page-top { padding-top: 7rem; }
  footer { flex-direction: column; text-align: center; margin: 1rem 0.6rem; }
}
