/* ---------- Tokens ---------- */
:root {
  --bg: #F7F4EE;
  --bg-elevated: #FFFFFF;
  --bg-translucent: rgba(247, 244, 238, 0.85);
  --text: #1A1A1A;
  --text-muted: #5A554C;
  --text-subtle: #8A8378;
  --accent: #B8722C;
  --accent-soft: rgba(184, 114, 44, 0.12);
  --rule: #DDD7C9;

  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --content-max: 1080px;
  --pad-x: clamp(1.25rem, 4vw, 2.5rem);
  --pad-y: clamp(2rem, 6vw, 4rem);
  --section-gap: clamp(3rem, 7vw, 5rem);
  --nav-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E10;
    --bg-elevated: #17171A;
    --bg-translucent: rgba(14, 14, 16, 0.85);
    --text: #E8E3D8;
    --text-muted: #B0AA9F;
    --text-subtle: #7A7468;
    --accent: #D8924A;
    --accent-soft: rgba(216, 146, 74, 0.15);
    --rule: #2A2925;
  }
}

:root[data-theme="light"] {
  --bg: #F7F4EE;
  --bg-elevated: #FFFFFF;
  --bg-translucent: rgba(247, 244, 238, 0.85);
  --text: #1A1A1A;
  --text-muted: #5A554C;
  --text-subtle: #8A8378;
  --accent: #B8722C;
  --accent-soft: rgba(184, 114, 44, 0.12);
  --rule: #DDD7C9;
}

:root[data-theme="dark"] {
  --bg: #0E0E10;
  --bg-elevated: #17171A;
  --bg-translucent: rgba(14, 14, 16, 0.85);
  --text: #E8E3D8;
  --text-muted: #B0AA9F;
  --text-subtle: #7A7468;
  --accent: #D8924A;
  --accent-soft: rgba(216, 146, 74, 0.15);
  --rule: #2A2925;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 1.5rem); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 150ms ease, color 150ms ease;
}

img { max-width: 100%; display: block; }
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease, color 150ms ease;
}
a:hover, a:focus-visible { border-bottom-color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

ul { margin: 0; padding: 0; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  z-index: 200;
  border: none;
  border-radius: 6px;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Top nav ---------- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-translucent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.top-nav-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0.85rem var(--pad-x);
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: clamp(0.85rem, 2.5vw, 1.75rem);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.nav-links a {
  color: var(--text-muted);
  border-bottom-color: transparent;
  padding: 0.25rem 0;
}
.nav-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.nav-links a.active { color: var(--accent); border-bottom-color: var(--accent); }

@media (max-width: 480px) {
  .top-nav-inner { padding-left: 1rem; padding-right: 1rem; }
  .nav-links { gap: 0.85rem; font-size: 0.78rem; }
}

/* ---------- Theme toggle ---------- */
#theme-toggle {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 150ms ease, border-color 150ms ease;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
#theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#theme-toggle svg { width: 16px; height: 16px; }

#theme-toggle .icon-sun { display: none; }
#theme-toggle .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) #theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) #theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ---------- Layout ---------- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--pad-y) var(--pad-x);
}

section { margin-top: var(--section-gap); }

.prose p { margin: 0 0 1rem; color: var(--text); }
.prose p:last-child { margin-bottom: 0; }

p { margin: 0; }

/* ---------- Section header (PCB-trace style) ---------- */
.section-header {
  position: relative;
  margin: 0 0 2rem;
  padding-top: 1.85rem;
  border-top: 1px dashed var(--rule);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--font-mono);
}
.section-header::before,
.section-header::after {
  content: '';
  position: absolute;
  top: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}
.section-header::before { left: -2px; }
.section-header::after { right: -2px; }
.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--accent);
  flex-shrink: 0;
}
.section-icon svg { width: 16px; height: 16px; }
.section-title {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  font-family: var(--font-mono);
  line-height: 1;
}

/* ---------- Hero ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.hero-photo {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--rule);
}
.hero-meta { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.hero-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
  color: var(--text);
}
.hero-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hero-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.hero-tagline {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}
.hero-cursor {
  display: inline-block;
  width: 0.4em;
  height: 0.95em;
  margin-left: 0.12em;
  background: var(--accent);
  vertical-align: -0.08em;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero-location {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-subtle);
  margin: 0.25rem 0 0;
}

@media (min-width: 640px) {
  .hero {
    flex-direction: row;
    align-items: center;
    gap: 2rem;
  }
  .hero-photo { width: 160px; height: 160px; }
}

/* ---------- Role list (PCB trace timeline) ---------- */
.role-list {
  position: relative;
  padding-top: 0.5rem;
}
.role {
  position: relative;
  padding-left: 2.25rem;
  padding-bottom: 2.5rem;
  border-left: 1px dashed var(--rule);
  margin-left: 4px;
}
.role:last-child {
  padding-bottom: 0.25rem;
  border-left-color: transparent;
}
.role::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 0.4rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  z-index: 1;
}
.role-header { margin-bottom: 0.6rem; }
.role-title {
  font-family: var(--font-sans);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.3rem;
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.role-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}
.role-note {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-subtle);
  font-style: italic;
  margin: 0.5rem 0 0;
}
.role--compact { padding-bottom: 1.5rem; }
.role--compact .role-header { margin-bottom: 0; }

/* ---------- Projects (collapsible under Crea) ---------- */
.projects {
  margin-top: 1.5rem;
  border-top: 1px dashed var(--rule);
  padding-top: 1rem;
}
.projects > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  user-select: none;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease;
}
.projects > summary::-webkit-details-marker { display: none; }
.projects > summary:hover { border-bottom-color: var(--accent); }
.projects > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
.projects-toggle-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  flex-shrink: 0;
}
.projects-toggle-icon::before,
.projects-toggle-icon::after {
  content: '';
  position: absolute;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.projects-toggle-icon::before { width: 7px; height: 1px; }
.projects-toggle-icon::after { width: 1px; height: 7px; transition: transform 150ms ease; }
.projects[open] .projects-toggle-icon::after { transform: translate(-50%, -50%) scaleY(0); }
.projects-toggle-count { color: var(--text-subtle); font-weight: 400; }

.project-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  counter-reset: project;
}
.project {
  position: relative;
  padding: 1.25rem 0 0;
  border-top: 1px dashed var(--rule);
  counter-increment: project;
}
.project:first-child { border-top: none; padding-top: 0; }
.project-name {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.4rem;
  letter-spacing: -0.005em;
}
.project-name::before {
  content: counter(project, decimal-leading-zero);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-right: 0.6rem;
  letter-spacing: 0.04em;
}
.project-desc {
  margin: 0 0 0.65rem;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
}
.project-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  margin: 0;
  padding: 0;
}
.project-tags li {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
  background: var(--bg-elevated);
}

@media (prefers-reduced-motion: reduce) {
  .projects-toggle-icon::after { transition: none; }
}

/* ---------- Skills (BOM-style row layout) ---------- */
.skill-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0;
}
.skill-row {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 1.25rem;
  align-items: baseline;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed var(--rule);
}
.skill-row:last-child { border-bottom: none; padding-bottom: 0; }
.skill-label {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin: 0;
}
.skill-row dd { margin: 0; }
.skill-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
}
.skill-tags li {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
  background: var(--bg-elevated);
  transition: border-color 150ms ease, color 150ms ease;
}
.skill-tags li:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 640px) {
  .skill-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
}

/* ---------- Contact ---------- */
.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 1rem 0 0;
}
.contact-list li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  flex-wrap: wrap;
}
.contact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--accent);
  flex-shrink: 0;
}
.contact-icon svg { width: 16px; height: 16px; }
.contact-label {
  color: var(--text-subtle);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  min-width: 4.5rem;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2rem var(--pad-x) var(--pad-y);
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-subtle);
  text-align: center;
}
.site-footer p { margin: 0; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-cursor { animation: none; }
  body, a, #theme-toggle, .skill-tags li, .nav-links a { transition: none; }
}

/* ---------- Print ---------- */
@media print {
  .top-nav, #theme-toggle, .skip-link { display: none; }
  body { background: #fff; color: #000; }
  html { scroll-padding-top: 0; }
  .section-header { border-color: #ccc; }
  .skill-tags li, .section-icon, .contact-icon { border-color: #ccc; background: #fff; }
  .role { border-color: #ccc; }
}

/* ---------- Larger viewport refinements ---------- */
@media (min-width: 960px) {
  body { font-size: 17px; }
}
