/* ─────────────────────────────────────────────────────────────
   Light / dark theme.
   theme.js sets <html data-theme="light|dark">. Light is the site's
   original look, so only dark needs rules.

   How dark works: the pages are built from Tailwind utilities, which
   read their colours from CSS variables (--color-neutral-800 etc).
   In dark mode the neutral scale is flipped on <html>, so every light
   surface and its text follow automatically. Sections that were
   already dark or brand-coloured ("islands": navbar, footer, green /
   black / amber blocks) get the original values back, so they look
   exactly as they do in light mode.
   ───────────────────────────────────────────────────────────── */

html[data-theme="dark"] {
  color-scheme: dark;

  --bt-page: #0b0f0c;
  --bt-surface: #141a16;

  --color-neutral-50: #1a211c;
  --color-neutral-100: #232b25;
  --color-neutral-200: #2e3731;
  --color-neutral-300: #4a554d;
  --color-neutral-400: #98a19a;
  --color-neutral-500: #a8b0aa;
  --color-neutral-600: #c2c8c3;
  --color-neutral-700: #d6dad7;
  --color-neutral-800: #e6e9e6;
  --color-neutral-900: #f4f6f4;
  --color-amber-50: #3a2e12;
}

/* Islands: restore Tailwind's original palette inside them. */
html[data-theme="dark"]
  :is(
    header,
    footer,
    #preloader,
    .bg-black,
    .bg-neutral-900,
    .bg-neutral-800,
    .bg-amber-500,
    .bg-amber-400,
    [class~="bg-[#1e3322]"],
    [class~="bg-[#122415]"],
    [class~="bg-[#000000]"],
    [class~="bg-[#25D366]"],
    [class~="bg-[#0077B5]"]
  ) {
  --color-neutral-50: oklch(98.5% 0 0);
  --color-neutral-100: oklch(97% 0 0);
  --color-neutral-200: oklch(92.2% 0 0);
  --color-neutral-300: oklch(87% 0 0);
  --color-neutral-400: oklch(70.8% 0 0);
  --color-neutral-500: oklch(55.6% 0 0);
  --color-neutral-600: oklch(43.9% 0 0);
  --color-neutral-700: oklch(37.1% 0 0);
  --color-neutral-800: oklch(26.9% 0 0);
  --color-neutral-900: oklch(20.5% 0 0);
  --color-amber-50: oklch(98.7% 0.022 95.277);
}

/* Page background (each page sets #f7f8f6 on body in its own <style>). */
html[data-theme="dark"] body {
  background-color: var(--bt-page);
}

/* White cards become dark surfaces — except inside islands, where a
   white button or card on green/black should stay white. */
html[data-theme="dark"] .bg-white {
  background-color: var(--bt-surface);
}
html[data-theme="dark"]
  :is(
    header,
    footer,
    .bg-black,
    .bg-neutral-900,
    .bg-neutral-800,
    [class~="bg-[#1e3322]"],
    [class~="bg-[#122415]"],
    [class~="bg-[#000000]"]
  )
  .bg-white {
  background-color: #fff;
}

/* Brand-green text and borders are unreadable on a dark page: lighten
   them, but keep the original green on white/amber/island elements. */
html[data-theme="dark"] [class~="text-[#1e3322]"] {
  color: #a7d9b3;
}
html[data-theme="dark"]
  :is(
    header,
    footer,
    .bg-black,
    .bg-neutral-900,
    .bg-neutral-800,
    .bg-amber-500,
    .bg-amber-400,
    [class~="bg-[#1e3322]"],
    [class~="bg-[#122415]"],
    [class~="bg-[#000000]"]
  )
  [class~="text-[#1e3322]"],
html[data-theme="dark"] :is(.bg-amber-500, .bg-amber-400)[class~="text-[#1e3322]"] {
  color: #1e3322;
}
html[data-theme="dark"] [class~="border-[#1e3322]"] {
  border-color: #3d6a48;
}

/* Timeline dots use a white ring to "cut out" of the page. */
html[data-theme="dark"] .border-white {
  border-color: var(--bt-page);
}

/* Icon tiles that flip to near-black on hover: use amber instead, so
   the white icon stays visible on a dark page. */
html[data-theme="dark"] .group:hover .group-hover\:bg-neutral-900 {
  background-color: #f59e0b;
}

/* Tech-stack logos are black SVGs. */
html[data-theme="dark"] img[src*="cdn.simpleicons.org"] {
  filter: invert(1);
}

/* Loading skeletons (work + admin pages). */
html[data-theme="dark"] .loading-shimmer {
  background-image: linear-gradient(
    90deg,
    #1a211c 25%,
    #232b25 50%,
    #1a211c 75%
  );
}

/* ── Theme switch button (injected into the navbar by theme.js) ── */
.theme-toggle {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 0.875rem;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s;
}
.theme-toggle:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1e3322;
}
.theme-toggle:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}
