/* ── Fonts ── */
:root {
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── Dark tokens (default) ── */
:root {
  --t1: #ffffff;
  --t2: rgba(255,255,255,0.65);
  --t3: rgba(255,255,255,0.40);
  --t4: rgba(255,255,255,0.24);
  --s1: rgba(25,28,31,0.40);
  --s2: rgba(25,28,31,0.65);
  --bd: rgba(255,255,255,0.08);
  --bd-h: rgba(255,255,255,0.15);
  --tag-bg: rgba(255,255,255,0.06);
}

/* ── Light tokens via OS ── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --t1: #0b0c0e;
    --t2: rgba(0,0,0,0.60);
    --t3: rgba(0,0,0,0.45);
    --t4: rgba(0,0,0,0.30);
    --s1: rgba(255,255,255,0.75);
    --s2: rgba(255,255,255,0.85);
    --bd: rgba(0,0,0,0.10);
    --bd-h: rgba(0,0,0,0.20);
    --tag-bg: rgba(0,0,0,0.05);
  }
}

/* ── Light tokens via manual toggle ── */
:root[data-theme="light"] {
  --t1: #0b0c0e;
  --t2: rgba(0,0,0,0.60);
  --t3: rgba(0,0,0,0.45);
  --t4: rgba(0,0,0,0.30);
  --s1: rgba(255,255,255,0.75);
  --s2: rgba(255,255,255,0.85);
  --bd: rgba(0,0,0,0.10);
  --bd-h: rgba(0,0,0,0.20);
  --tag-bg: rgba(0,0,0,0.05);
}

/* ── Nav frosted in light mode ── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) #nav,
  :root:not([data-theme="dark"]) #mobile-menu {
    --s2: rgba(200,202,210,0.55);
    --bd: rgba(0,0,0,0.12);
  }
}
:root[data-theme="light"] #nav,
:root[data-theme="light"] #mobile-menu {
  --s2: rgba(200,202,210,0.55);
  --bd: rgba(0,0,0,0.12);
}

/* ── Smooth theme transition ── */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition:
    background-color 300ms ease,
    color 300ms ease,
    border-color 300ms ease,
    fill 300ms ease,
    stroke 300ms ease !important;
  transition-delay: 0s !important;
}

/* ── Page intro overlay ── */
#page-intro {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #0b0c0e;
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  background: #0b0c0e;
  color: #fff;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) body { background: #f4f4f2; color: #0b0c0e; }
}
html[data-theme="light"] body { background: #f4f4f2; color: #0b0c0e; }
html[data-theme="dark"]  body { background: #0b0c0e; color: #fff; }

/* ── Backgrounds ── */
.bg-light { display: none; }
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .bg-dark  { display: none; }
  html:not([data-theme="dark"]) .bg-light { display: block; }
}
html[data-theme="light"] .bg-dark  { display: none; }
html[data-theme="light"] .bg-light { display: block; }
html[data-theme="dark"]  .bg-light { display: none; }
html[data-theme="dark"]  .bg-dark  { display: block; }

/* ── Focus rings ── */
a:focus-visible,
button:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid #494fdf;
  outline-offset: 3px;
  border-radius: 6px;
}

a, button, [role="button"] { cursor: pointer; }

/* ── Skip link ── */
.skip-link {
  position: fixed;
  top: -80px;
  left: 20px;
  z-index: 9999;
  background: #494fdf;
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }

/* ── Selection ── */
::selection { background: rgba(73,79,223,0.30); color: #fff; }

/* ── Nav ── */
.nav-link:hover  { color: var(--t1) !important; }
.nav-link--active { color: var(--t1) !important; }
#theme-toggle:hover, #theme-toggle-mobile:hover { color: var(--t1) !important; }
#theme-toggle, #theme-toggle-mobile { background: transparent; border: none; }

/* ── Nav lamp ── */
#nav-lamp {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: calc(100% + 8px);
  left: 0;
  width: 80px;
  border-radius: 9999px;
  background: transparent;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}
.nav-lamp-bar {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
  height: 2px;
  background: #ffffff;
  border-radius: 9999px;
  box-shadow: 0 0 8px 2px rgba(255,255,255,0.8), 0 0 20px 4px rgba(255,255,255,0.3);
}
.nav-lamp-glow-1, .nav-lamp-glow-2 { display: none; }

.bar {
  display: block; width: 22px; height: 2px;
  background: var(--t1); border-radius: 2px;
  transition: all .25s ease;
}

@media (max-width: 640px) {
  #nav          { display: none !important; }
  #hamburger    { display: flex !important; }
  section { padding-left: 20px !important; padding-right: 20px !important; }
  footer  { flex-direction: column !important; gap: 12px !important; text-align: center !important; }
}

/* ── Tahoe glass text ── */
@keyframes shimmer {
  0%   { background-position: 200% center; }
  100% { background-position:   0% center; }
}
.tahoe-glass-text {
  color: transparent !important;
  background: linear-gradient(135deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0.4) 25%, rgba(255,255,255,0.1) 45%, rgba(255,255,255,0.9) 55%, rgba(255,255,255,0.2) 75%, rgba(255,255,255,1) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1.5px rgba(255,255,255,0.28);
  filter: drop-shadow(0 15px 35px rgba(0,0,0,0.4)) drop-shadow(0 5px 10px rgba(0,0,0,0.2));
  animation: shimmer 8s linear infinite;
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .tahoe-glass-text {
    background: linear-gradient(135deg, rgba(11,12,14,1) 0%, rgba(11,12,14,0.5) 25%, rgba(11,12,14,0.15) 45%, rgba(11,12,14,0.85) 55%, rgba(11,12,14,0.3) 75%, rgba(11,12,14,1) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-stroke: 1.5px rgba(0,0,0,0.12);
    filter: drop-shadow(0 8px 20px rgba(0,0,0,0.12));
  }
}
html[data-theme="light"] .tahoe-glass-text {
  background: linear-gradient(135deg, rgba(11,12,14,1) 0%, rgba(11,12,14,0.5) 25%, rgba(11,12,14,0.15) 45%, rgba(11,12,14,0.85) 55%, rgba(11,12,14,0.3) 75%, rgba(11,12,14,1) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 1.5px rgba(0,0,0,0.12);
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.12));
}

/* ── Hero buttons ── */
.btn-accent:hover {
  background: #e8e8e8 !important;
  border-color: #e8e8e8 !important;
  box-shadow: 0 0 32px rgba(255,255,255,.25) !important;
  transform: translateY(-1px);
}

.btn-accent-arrow {
  display: inline-flex;
  align-items: center;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 0.35s ease, opacity 0.25s ease, transform 0.3s ease;
}
.btn-accent-arrow--left  { transform: translateX(10px); }
.btn-accent-arrow--right { transform: translateX(-10px); }
.btn-accent:hover .btn-accent-arrow {
  max-width: 22px;
  opacity: 1;
}
.btn-accent:hover .btn-accent-arrow--left  { transform: translateX(0); }
.btn-accent:hover .btn-accent-arrow--right { transform: translateX(0); }

.btn-liquid {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .01em;
  border-radius: 12px;
  padding: 14px 32px;
  text-decoration: none;
  color: var(--t1);
  background: transparent;
  cursor: pointer;
  transition: transform 300ms ease;
}
.btn-liquid:hover { transform: scale(1.05); }

@property --shiny-x {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 100%;
}
@keyframes shiny-sweep {
  0%   { --shiny-x: 100%; opacity: 0; }
  4%   { opacity: 1; }
  56%  { opacity: 1; }
  62%  { --shiny-x: -100%; opacity: 0; }
  100% { --shiny-x: -100%; opacity: 0; }
}
.btn-liquid::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    -75deg,
    transparent                  calc(var(--shiny-x) +  0%),
    rgba(255,255,255,0.35)       calc(var(--shiny-x) + 10%),
    rgba(255,255,255,0.55)       calc(var(--shiny-x) + 13%),
    rgba(255,255,255,0.35)       calc(var(--shiny-x) + 18%),
    transparent                  calc(var(--shiny-x) + 26%)
  );
}
.btn-liquid:hover::after {
  animation: shiny-sweep 2s ease infinite;
}

.btn-liquid-shadow {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  z-index: 0;
  transition: box-shadow 250ms ease;
  box-shadow:
    0 0 8px rgba(0,0,0,.03),
    0 2px 6px rgba(0,0,0,.08),
    inset 3px 3px .5px -3.5px rgba(255,255,255,.09),
    inset -3px -3px .5px -3.5px rgba(255,255,255,.85),
    inset 1px 1px 1px -.5px rgba(255,255,255,.6),
    inset -1px -1px 1px -.5px rgba(255,255,255,.6),
    inset 0 0 6px 6px rgba(255,255,255,.12),
    inset 0 0 2px 2px rgba(255,255,255,.06),
    0 0 12px rgba(0,0,0,.15);
}
html[data-theme="light"] .btn-liquid-shadow {
  box-shadow:
    0 0 6px rgba(0,0,0,.03),
    0 2px 6px rgba(0,0,0,.08),
    inset 3px 3px .5px -3px rgba(0,0,0,.9),
    inset -3px -3px .5px -3px rgba(0,0,0,.85),
    inset 1px 1px 1px -.5px rgba(0,0,0,.6),
    inset -1px -1px 1px -.5px rgba(0,0,0,.6),
    inset 0 0 6px 6px rgba(0,0,0,.12),
    inset 0 0 2px 2px rgba(0,0,0,.06),
    0 0 12px rgba(255,255,255,.15);
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .btn-liquid-shadow {
    box-shadow:
      0 0 6px rgba(0,0,0,.03),
      0 2px 6px rgba(0,0,0,.08),
      inset 3px 3px .5px -3px rgba(0,0,0,.9),
      inset -3px -3px .5px -3px rgba(0,0,0,.85),
      inset 1px 1px 1px -.5px rgba(0,0,0,.6),
      inset -1px -1px 1px -.5px rgba(0,0,0,.6),
      inset 0 0 6px 6px rgba(0,0,0,.12),
      inset 0 0 2px 2px rgba(0,0,0,.06),
      0 0 12px rgba(255,255,255,.15);
  }
}
.btn-liquid-glass {
  position: absolute;
  inset: 0;
  isolation: isolate;
  z-index: -1;
  overflow: hidden;
  border-radius: 12px;
  backdrop-filter: url('#hero-glass-filter');
  -webkit-backdrop-filter: url('#hero-glass-filter');
}
.btn-liquid-content {
  position: relative;
  z-index: 10;
  pointer-events: none;
}

/* ── Book Cards ── */
.books-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: center;
}

.book-card {
  position: relative;
  width: 220px;
  height: 300px;
  perspective: 2000px;
  transition: transform 0.4s ease, filter 0.4s ease;
}

.book-inner {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--s1);
  border: 1px solid var(--bd);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 1px 1px 16px rgba(0,0,0,0.35);
  overflow: hidden;
}

.book-badge {
  display: inline-flex;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid;
  width: fit-content;
}
.book-badge--os   { background: rgba(73,79,223,.12); border-color: rgba(73,79,223,.25); color: #7b80ee; }
.book-badge--prod { background: rgba(0,168,126,.12); border-color: rgba(0,168,126,.25); color: #00c99a; }

.book-inner-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--t1);
  line-height: 1.2;
}

.book-inner-desc {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.55;
  color: var(--t2);
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.book-tags span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--tag-bg);
  border: 1px solid var(--bd);
  color: var(--t3);
  letter-spacing: .02em;
}

.book-inner-link {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: rgba(73,79,223,.85);
  text-decoration: none;
  transition: color .2s ease;
  margin-top: auto;
}
.book-inner-link:hover { color: #6b71ee; }

.book-cover {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  box-shadow: 1px 1px 16px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.book-card:hover .book-cover { transform: rotateY(-80deg); }

.book-cover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.book-cover-badge {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.book-cover-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.book-cover-year {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  letter-spacing: .06em;
}

.book-cover--indigo { background: linear-gradient(145deg, #0f1035, #494fdf); }
.book-cover--teal   { background: linear-gradient(145deg, #022c22, #00a87e); }
.book-cover--purple { background: linear-gradient(145deg, #2e1065, #6d28d9); }
.book-cover--orange { background: linear-gradient(145deg, #1e3a8a, #494fdf); }
.book-cover--rose   { background: linear-gradient(145deg, #065f46, #00a87e); }
.book-cover--cyan   { background: linear-gradient(145deg, #312e81, #7b80ee); }

.books-grid:hover > .book-card:not(:hover) {
  filter: blur(3px);
  transform: scale(0.93);
}
.books-grid > .book-card:hover { transform: scale(1.04); }

@media (hover: none) {
  .books-grid:hover > .book-card:not(:hover),
  .books-grid > .book-card:hover { filter: none; transform: none; }
  .book-card:hover .book-cover { transform: none; }
  .btn-liquid:hover::after { animation: none; }
}

/* ── Gooey text ── */
.gooey-wrap { display: flex; align-items: center; }

.gooey-inner {
  display: grid;
  align-items: center;
}

.gooey-span {
  grid-area: 1/1;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: clamp(16px, 1.5vw, 21px);
  font-weight: 600;
  color: var(--t1);
  user-select: none;
  letter-spacing: -0.01em;
  text-align: left;
}

/* ── Projects ── */
.project-card:hover {
  border-color: var(--bd-h) !important;
  transform: translateY(-4px) !important;
  box-shadow: 0 16px 48px rgba(0,0,0,.25) !important;
}
.card-link:hover { color: #6b71ee !important; }

/* ── Stack ── */
.stack-badge:hover {
  border-color: rgba(73,79,223,0.40) !important;
  background: rgba(73,79,223,0.10) !important;
  color: var(--t1) !important;
  transform: translateY(-1px);
}

/* ── About ── */
.btn-glass:hover  { background: rgba(255,255,255,0.12) !important; border-color: var(--bd-h) !important; }
.btn-ghost:hover  { border-color: var(--bd-h) !important; color: var(--t1) !important; }

/* ── Touch: disable hover effects ── */
@media (hover: none) {
  .btn-accent:hover, .btn-glass:hover, .btn-ghost:hover, .btn-cta:hover,
  .nav-link:hover, .stack-badge:hover, .project-card:hover, .card-link:hover,
  .btn-liquid:hover { all: revert; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #hero-title, #hero-sub, #hero-desc, #hero-ctas, #hero-scroll { opacity: 1 !important; transform: none !important; }
  .section-head, .project-card, .stack-row, #about-card { opacity: 1 !important; transform: none !important; }
  .stack-badge:hover { transform: none; }
}
