/* ===== PORTFOLIO SHARED STYLES ===== */

:root, [data-theme="dark"] {
  --ink: #0d0d0c;
  --ink-2: #161614;
  --ink-3: #1f1e1b;
  --line: #2a2823;
  --line-soft: #1e1c19;
  --paper: #f4efe6;
  --cream: #ebe3d2;
  --muted: #8a857a;
  --muted-2: #5c5850;
  --accent: #d4a356;
  --accent-2: #e9c98a;
  --accent-3: #c89244;
  --green: #6b8e5a;
  --red: #c47666;
  --nav-bg: rgba(13,13,12,0.72);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter Tight", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  --ink: #f5f1e8;        /* light cream — the new "background" */
  --ink-2: #ebe5d6;      /* slightly darker cream surface */
  --ink-3: #ddd5c2;      /* deeper cream for cards */
  --line: #c5bca6;       /* warm muted divider */
  --line-soft: #d8d0bc;  /* softer divider */
  --paper: #1a1814;      /* dark text on light bg */
  --cream: #2c2820;      /* secondary text */
  --muted: #6b6555;      /* muted text */
  --muted-2: #8a8472;    /* extra muted */
  --accent: #a67c2e;     /* deeper amber for contrast on light */
  --accent-2: #8a6622;
  --accent-3: #c89244;
  --green: #4a6b3a;      /* deeper green */
  --red: #a85638;        /* deeper red */
  --nav-bg: rgba(245,241,232,0.78);
}

/* Light-mode grain — needs to be dark dots on light bg */
[data-theme="light"] body::before {
  opacity: 0.10;
  filter: invert(1);
}

/* Light-mode atmospheric gradients — softer warm washes */
[data-theme="light"] body::after {
  background-image:
    radial-gradient(ellipse 900px 600px at 15% -5%, rgba(166,124,46,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 700px 500px at 95% 25%, rgba(166,124,46,0.05) 0%, transparent 55%),
    radial-gradient(ellipse 800px 600px at 85% 100%, rgba(74,107,58,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 600px 400px at 5% 75%, rgba(168,86,56,0.04) 0%, transparent 55%) !important;
}

/* Light-mode portrait — full color */
[data-theme="light"] .portrait img {
  filter: contrast(1.02) !important;
}

/* Light-mode grid pattern */
[data-theme="light"] .bg-grid {
  background-image:
    linear-gradient(rgba(166,124,46,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(166,124,46,0.06) 1px, transparent 1px);
}

/* Light-mode corner brackets and rules */
[data-theme="light"] .bg-rules::before,
[data-theme="light"] .bg-rules::after {
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(166,124,46,0.25) 8%,
    rgba(150,138,118,0.5) 30%,
    rgba(150,138,118,0.5) 70%,
    rgba(166,124,46,0.25) 92%,
    transparent 100%);
}

/* Marquee items in light mode */
[data-theme="light"] .marquee-item {
  color: var(--cream);
}

/* Article thumbnails stay dark in light mode (decorative) — add a frame */
[data-theme="light"] .article-thumb {
  background: #1f1e1b;
  border-bottom: 1px solid var(--line);
}

/* Hero SQL decoration in light mode */
[data-theme="light"] .hero-sql {
  color: rgba(107, 101, 85, 0.6);
  opacity: 0.65;
}

/* Portrait tag badge stays amber-on-cream */
[data-theme="light"] .portrait-tag {
  background: var(--accent);
  color: var(--ink);
}

/* Ensure subtle gradient hovers are visible in light mode */
[data-theme="light"] .about-meta .row:hover {
  background: linear-gradient(to right, rgba(166,124,46,0.08), transparent) !important;
}
[data-theme="light"] .project-row:hover {
  background: linear-gradient(to right, transparent, rgba(166,124,46,0.06), transparent) !important;
}

/* Pulsing brand dot — give it a glow in light mode too */
[data-theme="light"] .brand-dot {
  box-shadow: 0 0 12px rgba(166,124,46,0.5);
}

/* Scroll-top button in light mode */
[data-theme="light"] .scroll-top:hover {
  color: var(--ink);
}

/* Stronger nav border in light mode for clarity */
[data-theme="light"] nav {
  border-bottom-color: var(--line);
}

/* Selection */
[data-theme="light"] ::selection {
  background: var(--accent);
  color: #fff;
}

/* Smooth transitions on theme change */
body, nav, .marquee, .skills-bg, .articles-bg, .article-tile, .skill-card,
.project-row, .proj-stack span, .filter-chip, .btn, footer, .article-end,
.code, .figure, .pullquote, .callout, .related-tile, .compare-cell,
.metric, .portrait, .toc, .hero-image {
  transition: background-color 280ms ease, border-color 280ms ease, color 200ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (max-width: 900px) {
  body { cursor: auto; }
}

/* Custom cursor */
.cursor-dot, .cursor-ring {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  border-radius: 50%;
  transition: transform 0.15s ease, opacity 0.2s ease, width 0.3s ease, height 0.3s ease, background 0.3s ease;
  mix-blend-mode: difference;
}
.cursor-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  transform: translate(-50%, -50%);
}
.cursor-ring {
  width: 32px; height: 32px;
  border: 1px solid var(--paper);
  transform: translate(-50%, -50%);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.3s, height 0.3s, border-color 0.3s, background 0.3s;
}
.cursor-ring.hover {
  width: 56px; height: 56px;
  border-color: var(--accent);
  background: rgba(212,163,86,0.08);
}
@media (max-width: 900px) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* Grain overlay (top layer, very subtle) */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* Atmospheric gradient washes (dark theme — default) */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: -2;
  background-image:
    radial-gradient(ellipse 900px 600px at 15% -5%, rgba(212,163,86,0.14) 0%, transparent 55%),
    radial-gradient(ellipse 700px 500px at 95% 25%, rgba(212,163,86,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 800px 600px at 85% 100%, rgba(107,142,90,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 600px 400px at 5% 75%, rgba(196,118,102,0.05) 0%, transparent 55%);
}
[data-theme="light"] body::after,
body[data-theme="light"]::after {
  background-image:
    radial-gradient(ellipse 900px 600px at 15% -5%, rgba(166,124,46,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 700px 500px at 95% 25%, rgba(166,124,46,0.05) 0%, transparent 55%),
    radial-gradient(ellipse 800px 600px at 85% 100%, rgba(74,107,58,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 600px 400px at 5% 75%, rgba(168,86,56,0.04) 0%, transparent 55%);
}

/* Grid pattern layer (between gradient and content) */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    linear-gradient(rgba(212,163,86,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,163,86,0.035) 1px, transparent 1px);
  background-size: 80px 80px;
  background-position: -1px -1px;
  mask-image: radial-gradient(ellipse 1200px 800px at 50% 30%, black 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 1200px 800px at 50% 30%, black 0%, transparent 75%);
}

/* Side rule lines — editorial signature */
.bg-rules {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
.bg-rules::before,
.bg-rules::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(212,163,86,0.18) 8%,
    rgba(42,40,35,0.6) 30%,
    rgba(42,40,35,0.6) 70%,
    rgba(212,163,86,0.18) 92%,
    transparent 100%);
}
.bg-rules::before { left: 56px; }
.bg-rules::after  { right: 56px; }
@media (max-width: 1100px) {
  .bg-rules::before,
  .bg-rules::after { display: none; }
}

/* Corner brackets — decorative anchors */
.bg-rules .corner {
  position: absolute;
  width: 22px; height: 22px;
  border: 1px solid var(--accent);
  opacity: 0.55;
}
.bg-rules .corner.tl { top: 24px; left: 24px; border-right: 0; border-bottom: 0; }
.bg-rules .corner.tr { top: 24px; right: 24px; border-left: 0; border-bottom: 0; }
.bg-rules .corner.bl { bottom: 24px; left: 24px; border-right: 0; border-top: 0; }
.bg-rules .corner.br { bottom: 24px; right: 24px; border-left: 0; border-top: 0; }
@media (max-width: 1100px) {
  .bg-rules .corner { display: none; }
}

/* Faint vertical typographic mark on left edge */
.bg-mark {
  position: fixed;
  top: 50%;
  left: 18px;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.5em;
  color: rgba(138,133,122,0.35);
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  z-index: -1;
}
@media (max-width: 1100px) { .bg-mark { display: none; } }

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

a { color: inherit; text-decoration: none; }
button { font: inherit; background: none; border: none; color: inherit; cursor: pointer; }
@media (max-width: 900px) { button { cursor: pointer; } }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; }

/* ===== NAV ===== */
nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line-soft);
}
nav .inner {
  max-width: 1280px; margin: 0 auto;
  padding: 18px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--paper);
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.brand-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(212,163,86,0.6);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}
.nav-links {
  display: flex; gap: 36px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.nav-links a {
  color: var(--muted);
  transition: color 200ms;
  position: relative;
}
.nav-links a:hover { color: var(--paper); }
.nav-links a::after {
  content: ""; position: absolute;
  left: 0; bottom: -4px; height: 1px; width: 0;
  background: var(--accent);
  transition: width 240ms ease;
}
.nav-links a:hover::after { width: 100%; }
@media (max-width: 720px) { .nav-links { display: none; } }

/* Reveal animations */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 800ms cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 800ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.reveal.in { opacity: 1; transform: translateY(0); }
.reveal.d1 { transition-delay: 100ms; }
.reveal.d2 { transition-delay: 200ms; }
.reveal.d3 { transition-delay: 320ms; }
.reveal.d4 { transition-delay: 440ms; }
.reveal.d5 { transition-delay: 560ms; }

/* Footer */
footer {
  border-top: 1px solid var(--line-soft);
  padding: 32px 0;
  background: var(--ink-2);
}
.footer-row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  flex-wrap: wrap;
  gap: 16px;
}
.footer-row .right { display: flex; align-items: center; gap: 8px; }
.footer-row .dot {
  width: 6px; height: 6px; background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(107,142,90,0.6);
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  margin-left: 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
  transition: all 240ms ease;
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(15deg);
}
.theme-toggle svg {
  width: 14px; height: 14px;
  transition: transform 400ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 240ms;
  position: absolute;
}
.theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }
