/* Kevin Perez-Espinoza — portfolio styles.
   One stylesheet, no framework. The visual source of truth is DESIGN.md
   (a remix of the Vercel + Linear references in awesome-design-md-main/).
   Earlier themes are kept for reference: styles.taste.css, styles.light.css, styles.dark-glow.css. */

:root {
  --canvas: #ffffff;          /* cards, menus */
  --bg: #fafafa;              /* page */
  --inset: #f3f3f3;           /* screenshot frames, tags, nav hover */
  --hairline: #e6e6e6;
  --hairline-strong: #cfcfcf;
  --ink: #171717;
  --ink-soft: #4d4d4d;        /* secondary text, 8.4:1 on --bg */
  --mute: #666666;            /* captions, 5.5:1 on --bg */
  --accent: #0b57d0;
  --accent-tint: #e4edfb;
  --todo-bg: #fff3d6;
  --todo-ink: #5c3a00;
  --on-ink: #ffffff;          /* text on ink-filled buttons */
  --ink-hover: #383838;
  --header-bg: rgba(250, 250, 250, 0.85);
  --toy-bg: #171717;          /* the Tone toy stays a dark panel in both themes */
  color-scheme: light;

  --ring: 0 0 0 1px var(--hairline);
  --shadow-card: var(--ring), 0 1px 1px rgba(0, 0, 0, 0.02), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lift: var(--ring), 0 2px 2px rgba(0, 0, 0, 0.04), 0 12px 24px -8px rgba(0, 0, 0, 0.1);

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  --measure: 40rem;
  --label-col: 11rem;
  --pad: clamp(1rem, 5vw, 3rem);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

/* Dark theme: set by js/theme.js (data-theme), or by the system setting when JS is off.
   The two blocks hold the same values. Contrast on --bg: ink 16:1, ink-soft 8:1, mute 5.9:1, accent 7.4:1. */
:root[data-theme="dark"] {
  --canvas: #151517; --bg: #0b0b0c; --inset: #1e1e21; --hairline: #2a2a2e; --hairline-strong: #404046;
  --ink: #ededed; --ink-soft: #a8a8ad; --mute: #8e8e94; --accent: #79a6f6; --accent-tint: #15284a;
  --todo-bg: #3a2c09; --todo-ink: #ffe0a3; --on-ink: #0b0b0c; --ink-hover: #c8c8cc;
  --header-bg: rgba(11, 11, 12, 0.85); --toy-bg: #1a1a1d;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #151517; --bg: #0b0b0c; --inset: #1e1e21; --hairline: #2a2a2e; --hairline-strong: #404046;
    --ink: #ededed; --ink-soft: #a8a8ad; --mute: #8e8e94; --accent: #79a6f6; --accent-tint: #15284a;
    --todo-bg: #3a2c09; --todo-ink: #ffe0a3; --on-ink: #0b0b0c; --ink-hover: #c8c8cc;
    --header-bg: rgba(11, 11, 12, 0.85); --toy-bg: #1a1a1d;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); scroll-padding-top: 5rem; /* clears the sticky header */ }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* Keep the footer at the bottom on short pages. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Scroll reveal (js/reveal.js adds these classes when motion is allowed). */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.in { opacity: 1; transform: none; }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
/* Standalone links (not inline in prose) get at least a 24px tap target. */
.case-head .back, .facts dd a, .section-body > p > a:only-child { display: inline-block; padding-block: 0.15rem; }

.skip-link { position: absolute; left: var(--pad); top: -4rem; background: var(--ink); color: var(--on-ink); padding: 0.6rem 1rem; border-radius: var(--r-md); z-index: 30; text-decoration: none; }
.skip-link:focus { top: 0.5rem; }

.wrap { max-width: 72rem; margin: 0 auto; padding: 0 var(--pad); }

/* ---------- Header: sticky bar with a bottom hairline ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--header-bg); -webkit-backdrop-filter: saturate(180%) blur(8px); backdrop-filter: saturate(180%) blur(8px); box-shadow: 0 1px 0 var(--hairline); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 4rem; gap: 1rem; position: relative; }
.wordmark { font-weight: 600; font-size: 0.95rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.wordmark:hover { color: var(--ink); opacity: 0.75; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.25rem; }
.site-nav a { display: block; text-decoration: none; font-size: 0.875rem; padding: 0.4rem 0.8rem; border-radius: 9999px; color: var(--ink-soft); }
.site-nav a:hover { color: var(--ink); background: var(--inset); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 500; background: var(--inset); }
.nav-toggle { display: none; font: inherit; font-size: 0.875rem; font-weight: 500; background: var(--canvas); border: 0; box-shadow: var(--ring); border-radius: var(--r-md); color: var(--ink); padding: 0.45rem 0.9rem; cursor: pointer; }
.nav-toggle:hover { background: var(--inset); }
.header-end { display: flex; align-items: center; gap: 0.5rem; }
/* Theme switch: a moon in light mode, a sun in dark mode. Hidden until js/theme.js runs. */
.theme-toggle { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; background: var(--canvas); border: 0; box-shadow: var(--ring); border-radius: var(--r-md); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--inset); }
.theme-toggle[hidden] { display: none; }
.theme-toggle svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Layout primitives ---------- */
main { flex: 1 0 auto; padding-bottom: 6rem; }
.section { display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); gap: 0 2.5rem; padding: 6rem 0 0; }
.section > h2 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
.section-wide { grid-template-columns: 1fr; }
.section-wide > h2 { margin-bottom: 1.5rem; font-size: 1.5rem; letter-spacing: -0.035em; }
.section-body > :first-child { margin-top: 0; }
.section-body > :last-child { margin-bottom: 0; }

h1, h3 { font-weight: 600; line-height: 1.15; letter-spacing: -0.025em; }
h1 { font-size: clamp(2.75rem, 7vw, 4.75rem); margin: 0 0 0.75rem; letter-spacing: -0.05em; line-height: 1; }
h3 { font-size: 1.125rem; margin: 2rem 0 0.5rem; }
p { margin: 0 0 1rem; }
.prose { max-width: var(--measure); }
.muted { color: var(--mute); }
.small { font-size: 0.875rem; }
.more-link { margin-top: 1.25rem; }

/* ---------- Hero ---------- */
.hero { padding: 5rem 0 2rem; }
.hero .title { font-size: 1.25rem; font-weight: 500; color: var(--ink-soft); margin: 0 0 2rem; letter-spacing: -0.02em; }
.hero .lede { max-width: 38rem; font-size: 1.1875rem; line-height: 1.6; color: var(--ink-soft); }
.hero .lede:first-of-type { color: var(--ink); }
.hero-links { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 2.25rem; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr); gap: 3.5rem; align-items: end; padding: 4rem 0 0; }
.hero-grid .hero { padding: 0; }

.button { display: inline-flex; align-items: center; min-height: 2.75rem; text-decoration: none; padding: 0 1.25rem; font-size: 0.9375rem; font-weight: 500; background: var(--canvas); color: var(--ink); border: 0; border-radius: var(--r-md); box-shadow: var(--ring); }
.button:hover { background: var(--inset); color: var(--ink); }
.button.primary { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.button.primary:hover { background: var(--ink-hover); color: var(--on-ink); }

/* ---------- Cards ---------- */
.card { background: var(--canvas); padding: 1.5rem; border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.bento { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.card-id { display: flex; align-items: center; gap: 1rem; }
.avatar { flex: none; width: 3rem; height: 3rem; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--on-ink); font-weight: 600; font-size: 0.95rem; letter-spacing: -0.02em; }
.card h2, .card .card-title { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.015em; }
.card .card-sub { margin: 0.2rem 0 0; font-size: 0.875rem; color: var(--ink-soft); line-height: 1.5; }
.card .tags { margin-top: 0.9rem; }

.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.tags li { font-family: var(--mono); font-size: 0.75rem; line-height: 1.4; background: var(--inset); padding: 0.25rem 0.55rem; border-radius: var(--r-sm); box-shadow: var(--ring); color: var(--ink); }

/* ---------- Project cards (grid) ---------- */
.work-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.work-card { margin: 0; container-type: inline-size; }
.work-link { display: block; height: 100%; text-decoration: none; color: var(--ink); background: var(--canvas); padding: 0.375rem; border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.work-link:hover { box-shadow: var(--shadow-lift); color: var(--ink); }
.work-media { background: var(--inset); aspect-ratio: 4 / 3; display: grid; place-items: center; padding: 1.5rem 1.5rem 0; overflow: hidden; border-radius: var(--r-md); align-items: end; }
.work-media img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; border-radius: var(--r-sm) var(--r-sm) 0 0; box-shadow: var(--ring); }
.work-tile { width: 100%; height: 100%; background: var(--canvas); border-radius: var(--r-sm) var(--r-sm) 0 0; box-shadow: var(--ring); display: flex; flex-direction: column; justify-content: flex-end; gap: 0.5rem; padding: 1.5rem; }
.work-tile-name { font-size: clamp(1.4rem, 2.8vw, 2rem); font-weight: 600; letter-spacing: -0.045em; line-height: 1.05; }
.work-tile-stack { font-family: var(--mono); font-size: 0.75rem; color: var(--mute); line-height: 1.6; }
.work-meta { display: flex; flex-direction: column; gap: 0.9rem; padding: 1rem 1rem 0.9rem; }
.work-meta h3 { margin: 0 0 0.25rem; font-size: 1.125rem; letter-spacing: -0.025em; }
.work-meta p { margin: 0; font-size: 0.9375rem; color: var(--ink-soft); line-height: 1.5; max-width: 24rem; }
/* Tags sit beside the text only when the card is wide enough for both. */
@container (min-width: 30rem) {
  .work-meta { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 1rem; }
  .work-meta .tags { justify-content: flex-end; flex: none; max-width: 40%; }
}

/* ---------- Experience ---------- */
.role h3 { margin: 0; font-size: 1.375rem; letter-spacing: -0.03em; }
.role .meta { font-family: var(--mono); font-size: 0.8125rem; color: var(--mute); margin: 0.4rem 0 1.25rem; }
.plain-list { margin: 0 0 1rem; padding-left: 1.2rem; max-width: var(--measure); }
.plain-list li { margin-bottom: 0.6rem; padding-left: 0.2rem; }
.plain-list li::marker { color: var(--accent); }

.skill-groups { margin: 0; }
.skill-groups dt { font-weight: 600; margin-top: 1.4rem; }
.skill-groups dt:first-child { margin-top: 0; }
.skill-groups dd { margin: 0.25rem 0 0; max-width: var(--measure); color: var(--ink-soft); }

/* ---------- Case study pages ---------- */
.case-head { padding: 4rem 0 0; }
.case-head .back { font-family: var(--mono); font-size: 0.8125rem; text-decoration: none; color: var(--mute); }
.case-head .back:hover { color: var(--ink); }
.case-head h1 { margin-top: 1.25rem; font-size: clamp(2.25rem, 6vw, 4rem); letter-spacing: -0.045em; line-height: 1.02; }
.case-head .summary { font-size: 1.1875rem; color: var(--ink-soft); max-width: 40rem; margin: 1rem 0 2.25rem; }
.facts { display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); gap: 1rem 2.5rem; margin: 0; padding: 1.5rem; background: var(--canvas); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.facts dt { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mute); padding-top: 0.3rem; }
.facts dd { margin: 0; }
.facts dd .muted { color: var(--ink-soft); }

.todo { background: var(--todo-bg); color: var(--todo-ink); padding: 0.8rem 1.1rem; margin: 0 0 1rem; max-width: var(--measure); font-size: 0.9375rem; border-radius: var(--r-md); }

.figure-slot { background: var(--canvas); padding: 1.5rem; max-width: var(--measure); color: var(--ink-soft); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; max-width: 48rem; }
.split h3 { margin-top: 0; font-size: 1rem; }

.shot { margin: 0; max-width: 100%; }
.shot img { display: block; width: 100%; height: auto; border-radius: var(--r-md); box-shadow: var(--shadow-card); }
.shot figcaption { margin-top: 0.75rem; font-size: 0.875rem; color: var(--mute); max-width: var(--measure); }
.diagram-fig { background: var(--canvas); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 1.5rem; }

/* Diagrams: white nodes on hairlines, one highlighted node, arrows in the muted gray. */
.diagram { display: block; width: 100%; height: auto; max-width: 48rem; }
.diagram .n { fill: var(--canvas); stroke: var(--hairline-strong); stroke-width: 1; }
.diagram .n.hl { fill: var(--accent-tint); stroke: var(--accent); }
.diagram .grp { fill: var(--inset); stroke: var(--hairline); }
.diagram .grp ~ .n { fill: var(--canvas); }
.diagram .grp ~ .n.hl { fill: var(--accent-tint); }
.diagram .n.dash, .diagram .grp ~ .n.dash { fill: none; stroke: var(--mute); stroke-width: 1.2; stroke-dasharray: 5 4; }
.diagram .t1 { font-family: var(--sans); font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.diagram .t2 { font-family: var(--sans); font-size: 11px; fill: var(--ink-soft); }
.diagram .t3 { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; fill: var(--mute); }
.diagram .a { stroke: var(--mute); stroke-width: 1.4; fill: none; }
.diagram .ah { fill: var(--mute); }
.diagram .dash { stroke-dasharray: 5 4; }

.case-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 5rem 0 0; font-size: 1rem; font-weight: 500; }

/* ---------- Tone toy: the one dark ink panel ---------- */
.pluck { max-width: var(--measure); display: flex; gap: 1.5rem; align-items: center; background: var(--toy-bg); color: #fff; box-shadow: var(--ring); }
.pluck .card-title { color: #fff; }
.pluck .card-sub { color: #b4b4b4; }
.knob { cursor: grab; touch-action: none; flex: none; width: 4.5rem; height: 4.5rem; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 0 0 4px #2e2e2e; transition: box-shadow 0.2s; }
.knob.grab { cursor: grabbing; }
.knob-face { display: block; width: 100%; height: 100%; border-radius: 50%; position: relative; transition: transform 0.15s ease-out; }
.knob-face::after { content: ""; position: absolute; left: 50%; top: 9%; width: 4px; height: 28%; margin-left: -2px; background: #171717; border-radius: 2px; }
.pluck.played .knob { box-shadow: 0 0 0 4px var(--accent); }
.pluck-body { flex: 1; min-width: 0; }
.wave { display: block; width: 7.5rem; height: 2.75rem; margin-top: 0.6rem; }
.wave-axis { stroke: #3a3a3a; stroke-width: 1; }
.wave-path { fill: none; stroke: #7fa8ee; stroke-width: 2; stroke-linejoin: round; }
.pluck-controls { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; margin-top: 0.8rem; }
.pluck-controls label { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: #b4b4b4; }
.pluck-controls output { color: #9dbcf2; margin-left: 0.4rem; font-variant-numeric: tabular-nums; }
.pluck-controls input[type="range"] { flex: 1 1 6rem; min-width: 6rem; accent-color: #7fa8ee; }
.pluck-controls .button { min-height: 2.5rem; cursor: pointer; background: #fff; color: #171717; box-shadow: none; }
.pluck-controls .button:hover { background: #e6e6e6; color: #171717; }
.pluck-controls .button:disabled { opacity: 0.5; cursor: default; }
.pluck :focus-visible { outline-color: #9dbcf2; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 2rem; padding: 2.5rem 0; font-size: 0.875rem; color: var(--mute); background: var(--bg); box-shadow: 0 -1px 0 var(--hairline); }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-footer a { color: var(--ink-soft); display: inline-block; padding-block: 0.15rem; }

/* ---------- Responsive ---------- */
@media (max-width: 52rem) {
  .section { grid-template-columns: 1fr; gap: 0.5rem; padding-top: 4.5rem; }
  .facts { grid-template-columns: 1fr; gap: 0.25rem; }
  .facts dd + dt { margin-top: 0.75rem; }
  .section > h2 { margin-bottom: 1rem; }
  .split { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; align-items: start; }
}
@media (max-width: 40rem) {
  .work-grid { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; min-height: 2.25rem; }
  .theme-toggle { order: -1; } /* sun/moon sits left of Menu on phones */
  .site-nav { position: absolute; right: var(--pad); top: calc(100% + 0.25rem); display: none; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0.125rem; padding: 0.375rem; min-width: 11rem; background: var(--canvas); border-radius: var(--r-lg); box-shadow: var(--shadow-lift); }
  .site-nav a { padding: 0.6rem 0.8rem; border-radius: var(--r-md); font-size: 0.9375rem; }
  .hero { padding: 3rem 0 1rem; }
  .hero-grid { padding-top: 2.5rem; }
  .pluck { flex-direction: column; align-items: flex-start; }
  .diagram-fig { padding: 1rem; }
}
@media (prefers-reduced-motion: no-preference) {
  a, .button, .nav-toggle, .site-nav a { transition: color 0.15s, background-color 0.15s, text-decoration-color 0.15s; }
  .work-link { transition: box-shadow 0.2s ease, transform 0.2s ease; }
  .work-link:hover { transform: translateY(-2px); }
}
@media print { .site-nav, .nav-toggle, .skip-link { display: none; } .site-header { position: static; } }
