/* ==========================================================================
   Personal Projects — base styles
   ========================================================================== */

/* --- Tokens ---------------------------------------------------------------- */
:root {
  --bg: 246, 247, 251;
  --surface: 255, 255, 255;
  --surface-2: 241, 242, 248;
  --fg: 17, 20, 32;
  --muted: 96, 102, 126;
  --border: 223, 226, 236;
  --accent: 79, 70, 229;
  --accent-2: 14, 165, 233;

  /* consumed by the canvas animation */
  --bg-accent: 79, 70, 229;
  --bg-line: 99, 102, 241;

  --panel: 255, 255, 255;
  --panel-alpha: 0.72;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -12px rgba(15, 20, 40, 0.25);
  --maxw: 1120px;
  --header-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: 9, 11, 18;
  --surface: 17, 20, 30;
  --surface-2: 24, 28, 40;
  --fg: 231, 234, 243;
  --muted: 148, 155, 180;
  --border: 40, 45, 62;
  --accent: 129, 140, 248;
  --accent-2: 56, 189, 248;

  --bg-accent: 129, 140, 248;
  --bg-line: 99, 102, 241;

  --panel: 15, 18, 28;
  --panel-alpha: 0.66;

  --shadow: 0 14px 40px -14px rgba(0, 0, 0, 0.7);
}

/* --- Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { background: rgb(var(--bg)); scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: rgb(var(--fg));
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: rgb(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); font-weight: 700; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }
code, kbd { font-family: var(--mono); font-size: 0.9em; }
kbd {
  padding: 0.1em 0.45em;
  border: 1px solid rgb(var(--border));
  border-bottom-width: 2px;
  border-radius: 6px;
  background: rgb(var(--surface-2));
  font-size: 0.8em;
}

:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; border-radius: 4px; }

.muted { color: rgb(var(--muted)); }

/* --- Background canvas ----------------------------------------------------- */
[data-bg] { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; display: block; }

/* --- Layout helpers -------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: rgb(var(--accent)); color: #fff; padding: 0.6rem 1rem; border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

/* --- Header ---------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(var(--panel), 0.6);
  border-bottom: 1px solid rgba(var(--border), 0.8);
}
.header-inner { display: flex; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: rgb(var(--fg)); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, rgb(var(--accent)), rgb(var(--accent-2)));
  box-shadow: 0 0 0 3px rgba(var(--accent), 0.15);
}
.site-nav { margin-left: auto; display: flex; gap: 0.25rem; }
.site-nav a {
  color: rgb(var(--fg)); padding: 0.45rem 0.7rem; border-radius: 8px; font-size: 0.95rem;
}
.site-nav a:hover { background: rgba(var(--accent), 0.12); text-decoration: none; }

.theme-toggle {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border: 1px solid rgb(var(--border)); border-radius: 10px;
  background: rgba(var(--surface), 0.6); color: rgb(var(--fg));
  cursor: pointer;
}
.theme-toggle:hover { border-color: rgba(var(--accent), 0.6); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* --- Hero ------------------------------------------------------------------ */
.hero { padding: clamp(3rem, 10vw, 6rem) 0 clamp(2rem, 6vw, 3.5rem); }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.78rem;
  font-weight: 700; color: rgb(var(--accent)); margin-bottom: 0.75rem;
}
.lede { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: rgb(var(--muted)); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0 1rem; }
.hint { font-size: 0.9rem; color: rgb(var(--muted)); }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.2rem; border-radius: 999px;
  font-weight: 600; font-size: 0.95rem;
  background: rgb(var(--accent)); color: #fff;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn-ghost { background: rgba(var(--surface), 0.5); color: rgb(var(--fg)); border-color: rgb(var(--border)); }

/* --- Sections -------------------------------------------------------------- */
.section { padding: clamp(1.75rem, 5vw, 3rem) 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-head h2 { margin: 0; }
.section-head .muted { margin: 0; font-size: 0.9rem; }

.panel {
  background: rgba(var(--panel), var(--panel-alpha));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.about-panel { max-width: 62ch; }

/* --- Filter chips ---------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.chips:empty { display: none; }
.chip {
  font: inherit; font-size: 0.85rem;
  padding: 0.4rem 0.85rem; border-radius: 999px;
  border: 1px solid rgb(var(--border)); background: rgba(var(--surface), 0.55);
  color: rgb(var(--fg)); cursor: pointer;
}
.chip:hover { border-color: rgba(var(--accent), 0.6); }
.chip.is-active { background: rgb(var(--accent)); border-color: rgb(var(--accent)); color: #fff; }

/* --- Project grid + cards -------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
#featured-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  display: flex; flex-direction: column;
  background: rgba(var(--panel), var(--panel-alpha));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-3px); border-color: rgba(var(--accent), 0.55); box-shadow: var(--shadow); }

.card-media {
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(var(--accent), 0.22), rgba(var(--accent-2), 0.22));
  color: rgb(var(--fg));
  font-size: 2.6rem; font-weight: 800; letter-spacing: -0.04em;
  border-bottom: 1px solid rgb(var(--border));
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }

.card-body { padding: 1.1rem 1.15rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.card-head { display: flex; align-items: center; gap: 0.6rem; }
.card-title { margin: 0; font-size: 1.1rem; }
.card-title a { color: rgb(var(--fg)); }
.card-desc { margin: 0; color: rgb(var(--muted)); font-size: 0.95rem; }

.badge {
  margin-left: auto; flex: none;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 999px;
  background: rgba(var(--accent), 0.16); color: rgb(var(--accent));
}

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0.25rem 0 0; }
.tags li {
  font-size: 0.72rem; font-family: var(--mono);
  padding: 0.15rem 0.5rem; border-radius: 6px;
  background: rgb(var(--surface-2)); color: rgb(var(--muted));
  border: 1px solid rgb(var(--border));
}

.card-links { margin-top: auto; padding-top: 0.75rem; display: flex; gap: 1rem; font-size: 0.9rem; font-weight: 600; }
.card-links .muted { font-weight: 400; font-size: 0.85rem; }

.empty {
  padding: 2rem; text-align: center; color: rgb(var(--muted));
  border: 1px dashed rgb(var(--border)); border-radius: var(--radius);
}

/* --- Social / footer ------------------------------------------------------- */
.social { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; padding: 0; margin: 0.5rem 0 0; }
.social a {
  display: inline-block; padding: 0.5rem 1rem; border-radius: 999px;
  border: 1px solid rgb(var(--border)); background: rgba(var(--surface), 0.5);
  color: rgb(var(--fg)); font-weight: 600; font-size: 0.9rem;
}
.social a:hover { text-decoration: none; border-color: rgba(var(--accent), 0.6); }

.site-footer { padding: 2rem 0 3rem; border-top: 1px solid rgba(var(--border), 0.7); margin-top: 2rem; }
.site-footer p { margin: 0; font-size: 0.85rem; }

/* --- 404 ------------------------------------------------------------------- */
.error-page { padding: clamp(4rem, 14vw, 8rem) 0; }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 640px) {
  .site-nav { display: none; }
  .brand-name { display: none; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
}
