/* ============================================================
   PORTFOLIO STYLES  —  minimalist-editorial (cool)
   ------------------------------------------------------------
   Palette + type are driven by CSS variables in :root, with a
   .dark override block for dark mode. You rarely need to edit
   this file, content lives in projects.js.

   Look: cool near-white canvas, serif reading text (Source Serif 4),
   monospace labels (JetBrains Mono), one restrained ink-blue
   accent. A narrow single reading column with lots of whitespace.
   ============================================================ */

/* ---------- Theme tokens (light) ---------- */
:root {
  /* Surfaces */
  --bg: #F2E9DE;            /* warm paper-cream page background (reverted to previous) */
  --surface: #FBF6EE;       /* thumbnails, quiet panels (warmed to match) */
  --band: #EFE7DA;          /* About section band (warmed to match) */
  --contact-bg: #EDE4D7;    /* quiet contact panel (warmed to match) */

  /* Text */
  --ink: #14181F;           /* headings / strong text */
  --body: #2E353E;          /* body reading copy */
  --muted: #656D78;         /* muted text */
  --muted-2: #838A94;       /* subtitles */
  --faint: #98A1AC;         /* mono eyebrows / meta */

  /* Accent (the ONE bold spot: links + live cue) */
  --accent: #2F5FD0;        /* ink-blue */
  --accent-ink: #FFFFFF;    /* text on the accent */
  --link: #2F5FD0;
  --dot: #2E9E86;           /* "available" green dot only */

  /* Lines & decoration */
  --border: #E7EBEF;        /* hairlines, thumb borders */
  --border-strong: #D3DAE1; /* ghost-button / input borders */
  --hairline: rgba(20, 24, 31, 0.08);
  --avatar-ring: #E7EBEF;
  --avatar-bg: #EEF1F4;
  --avatar-icon: #98A1AC;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.08);

  /* Category colour-coding (project cards) */
  --cat-health: #1D9E75;
  --cat-health-bg: #E1F5EE;
  --cat-health-text: #085041;
  --cat-other: #378ADD;
  --cat-other-bg: #E6F1FB;
  --cat-other-text: #0C447C;

  /* Type (Source Serif 4 reading, Inter UI, JetBrains mono labels). */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout */
  --maxw: 760px;            /* narrow editorial reading column */
  --radius: 10px;
  --radius-sm: 7px;
}

/* ---------- Theme tokens (dark) ---------- */
.dark {
  --bg: #0E1116;
  --surface: #171B21;
  --band: #12151A;
  --contact-bg: #12151A;

  --ink: #EAEEF3;
  --body: #C2C9D2;
  --muted: #8B939E;
  --muted-2: #767E89;
  --faint: #6E7681;

  --accent: #6B93F0;
  --accent-ink: #0E1116;
  --link: #6B93F0;
  --dot: #37B39A;

  --border: #232A32;
  --border-strong: #333B45;
  --hairline: rgba(255, 255, 255, 0.08);
  --avatar-ring: #232A32;
  --avatar-bg: #1B2027;
  --avatar-icon: #6E7681;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

  --cat-health: #37B39A;
  --cat-health-bg: rgba(29, 158, 117, 0.16);
  --cat-health-text: #9FE1CB;
  --cat-other: #6B93F0;
  --cat-other-bg: rgba(55, 138, 221, 0.16);
  --cat-other-text: #B5D4F4;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font-serif);   /* reading-first: serif is the default voice */
  font-size: 18px;                  /* large, comfortable base (easy on the eyes) */
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.18;
}

a { color: var(--link); }

/* A small monospace label, used for every section eyebrow + meta. */
.eyebrow, .hero-eyebrow, .section-title, .contact-title {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--faint);
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: 26px;
  padding-right: 26px;
}

/* Offset anchored sections so the sticky header doesn't cover them. */
#projects, #about, #contact, #top { scroll-margin-top: 84px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 0.5px solid var(--hairline);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 15px;
  padding-bottom: 15px;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links a {
  font-family: var(--font-mono);
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.nav-links a:hover { color: var(--ink); }

/* Dark-mode toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0.5px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; }

/* ---------- Hero ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 60px;
  padding-bottom: 52px;
}

.hero-text { width: 100%; }

/* Small avatar sits ABOVE the name (order: -1 pulls it before the text). */
.hero-avatar {
  order: -1;
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  margin-bottom: 26px;
  border-radius: 50%;
  border: 1px solid var(--avatar-ring);
  background: var(--avatar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-avatar svg { width: 34px; height: 34px; color: var(--avatar-icon); }
.hero-avatar img { width: 100%; height: 100%; object-fit: cover; }

.hero-eyebrow { margin: 0 0 16px; }

.hero-title {
  margin: 0 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.14;
  color: var(--ink);
  max-width: 18ch;
}

.hero-intro {
  margin: 0 0 28px;
  font-family: var(--font-serif);
  font-size: 18.5px;
  line-height: 1.75;
  color: var(--body);
  max-width: 56ch;
  white-space: pre-line;   /* honor line breaks (\n) typed in the intro */
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 0.5px solid transparent;
  transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--body);
  border-color: var(--border-strong);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }

.btn svg { width: 16px; height: 16px; }

/* ---------- Section heads ---------- */
.section { padding-top: 20px; padding-bottom: 44px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}

.section-title { margin: 0 0 6px; }
.section-subtitle {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--muted-2);
}

/* ---------- Filter pills (quiet mono text buttons) ---------- */
.filters { display: flex; gap: 16px; }

.filter {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  padding: 0;
  border: none;
  border-radius: 0;
  cursor: pointer;
  color: var(--faint);
  background: transparent;
  transition: color 0.2s ease;
}

.filter:hover { color: var(--ink); }
.filter.is-active { color: var(--accent); }
.filter:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }

/* ---------- Project cards (grid, big square screenshots) ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }

/* Thin colour bar = the category code (health / other) */
.card-accent { height: 3px; }
.card[data-category="health"] .card-accent { background: var(--cat-health); }
.card[data-category="other"] .card-accent { background: var(--cat-other); }

/* Big square thumbnail: a real screenshot, or a quiet panel with the icon */
.card-thumb {
  aspect-ratio: 1 / 1;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-thumb.has-image { cursor: zoom-in; }

/* A blurred, faded mirror of the screenshot fills the square behind it, so
   zooming below 100% shows a soft backdrop instead of empty background. */
.card-thumb-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(20px) grayscale(0.4);
  opacity: 0.4;
  transform: scale(1.2);
}

.card-thumb svg { width: 34px; height: 34px; position: relative; z-index: 1; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 1; }

.card-body { flex: 1; padding: 16px 18px 18px; min-width: 0; }

/* Title row: name on the left, live cue on the right */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--accent); }

/* Small "live" / "github" cue next to the title */
.card-cue {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  white-space: nowrap;
}

/* Tags rendered as small pills, tinted by the card's category colour */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.card-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 5px;
}
.card[data-category="health"] .card-tag { background: var(--cat-health-bg); color: var(--cat-health-text); }
.card[data-category="other"] .card-tag { background: var(--cat-other-bg); color: var(--cat-other-text); }

.card-desc {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
}

/* ---------- About band ---------- */
.section-band {
  background: var(--band);
  border-top: 0.5px solid var(--hairline);
  border-bottom: 0.5px solid var(--hairline);
  padding: 52px 0;
}

.about .section-title { margin-bottom: 16px; }
.about p {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.8;
  color: var(--body);
  max-width: 62ch;
}
.about p:last-child { margin-bottom: 0; }

/* ---------- Contact (quiet, left-aligned) ---------- */
.contact {
  background: var(--contact-bg);
  border-bottom: 0.5px solid var(--hairline);
  padding: 52px 0;
}

.contact-title { margin: 0 0 10px; }
.contact-line {
  margin: 0 0 22px;
  max-width: 46em;
  font-family: var(--font-serif);
  font-size: 16.5px;
  color: var(--body);
}

.contact-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Small icon-only social button (e.g. LinkedIn) */
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0.5px solid var(--border-strong);
  color: var(--muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.icon-link:hover { color: var(--ink); border-color: var(--ink); }
.icon-link:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.icon-link svg { width: 19px; height: 19px; }

/* Contact form (Formspree) */
.contact-form {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-form input[type="email"],
.contact-form textarea {
  width: 100%;
  padding: 11px 13px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.contact-form textarea { resize: vertical; min-height: 118px; }

.contact-form input:focus,
.contact-form textarea:focus {
  outline: 2px solid var(--link);
  outline-offset: 1px;
  border-color: var(--link);
}

.contact-form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.contact-status {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  min-height: 1.2em;
  color: var(--muted);
}
.contact-status.ok { color: var(--dot); }
.contact-status.err { color: #C2453E; }
.dark .contact-status.err { color: #F0928A; }

/* Visually-hidden labels (kept for screen readers) */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Footer ---------- */
.site-footer { padding: 30px 0 40px; }
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-name {
  margin: 0;
  font-family: var(--font-serif);
  color: var(--ink);
  font-size: 16px;
}
.footer-note {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--faint);
}

.noscript-note { color: var(--muted); }

/* ---------- Screenshot lightbox (click a card thumbnail to enlarge) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(20, 24, 31, 0.86);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}
.dark .lightbox { background: rgba(0, 0, 0, 0.88); }
.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  transform: scale(0.94);
  transition: transform 0.25s ease;
}
.lightbox.is-open .lightbox-content { transform: scale(1); }

.lightbox img {
  max-width: 100%;
  max-height: 65vh;
  display: block;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.lightbox-caption {
  max-width: 62ch;
  text-align: center;
  padding: 0 8px;
}
.lightbox-caption h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: #fff;
}
.lightbox-caption p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
  white-space: pre-line;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 460px) {
  .projects-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 17px; }
  .hero { padding-top: 40px; }
  .container { padding-left: 20px; padding-right: 20px; }
}

/* ---------- Respect reduced-motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
