/* ============================================================
   Layout and structure.

   This file contains NO colour, font or radius literals — every
   visual value comes from a token defined by the theme stylesheet
   (css/themes/*.css), which must be linked BEFORE this file.

   Swapping the theme <link> re-skins the site without touching
   anything here.
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--step1);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
p { margin: 0; }
img { max-width: 100%; display: block; }
a { color: inherit; }

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

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: 24px; }
@media (max-width: 560px) { .wrap { padding-inline: 18px; } }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 10px 16px;
  z-index: 200;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.mono {
  font-size: var(--step-1);
}

/* ============================================================
   Header / nav
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 54px;
}
.brand {
  font-size: var(--step0);
  text-decoration: none;
  white-space: nowrap;
}
.brand .brand-dot { color: var(--accent); }

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a {
  text-decoration: none;
  color: var(--fg-muted);
  font-size: var(--step-1);
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--fg); background: var(--bg-hover); }
.nav a[aria-current="page"] { color: var(--fg); }

.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle {
    display: inline-grid; place-items: center;
    margin-left: auto;
    width: 34px; height: 34px;
    background: transparent; color: var(--fg-muted);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .nav-toggle svg { width: 16px; height: 16px; }
  .nav {
    position: absolute; top: 54px; left: 0; right: 0;
    margin-left: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-strong);
    padding: 10px 18px 14px;
    box-shadow: var(--shadow-lg);
  }
  .nav[hidden] { display: none; }
  .nav a { padding: 10px 12px; }
}

/* ============================================================
   Section furniture
   ============================================================ */
.section { padding-block: 30px; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: none; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: var(--step1);
  color: var(--fg);
}
/* A dashed rule runs out from the label — the schematic's section divider. */
.section-head::after {
  content: "";
  flex: 1;
  height: 0;
  border-top: 1px dashed var(--border-strong);
  align-self: center;
}
.section-head .link-more { margin-left: 0; order: 3; }
.section-head .link-more { margin-left: auto; }

.link-more {
  font-size: var(--step-1);
  color: var(--fg-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all .15s;
  white-space: nowrap;
}
.link-more:hover { color: var(--fg); border-color: var(--border-strong); background: var(--bg-hover); }
.link-more::after { content: "→"; transition: transform .15s; }
.link-more:hover::after { transform: translateX(2px); }

.section-lede {
  color: var(--fg-muted);
  font-size: var(--step0);
  max-width: 62ch;
  margin-top: -10px;
  margin-bottom: 18px;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  /* Sized by its content rather than a fixed height: a hard height either
     clips the intro or leaves dead space when the text rewraps. The intro
     clamp below is what actually bounds it. */
  padding-block: 26px 24px;
}
.hero-body {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 860px) {
  .hero-body { -webkit-line-clamp: none; overflow: visible; }
}
.hero-eyebrow {
  font-size: var(--step-1);
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-eyebrow::after {
  content: "";
  width: 46px; height: 0;
  border-top: 1px solid var(--accent);
}
.hero h1 {
  font-size: var(--step5);
  max-width: 20ch;
  margin-bottom: 14px;
}
@media (max-width: 640px) { .hero h1 { font-size: var(--step4); } }
.hero-body { max-width: 64ch; color: var(--fg-muted); font-size: var(--step1); line-height: 1.5; }
.hero-body strong { color: var(--fg); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }

/* ============================================================
   Hero social icons — sit inline beside the CV button
   ============================================================ */
.social-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-left: 4px;
}
.social-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--fg-muted);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  transition: color .15s, border-color .15s, background .15s, transform .15s;
}
.social-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.social-btn svg { width: 16px; height: 16px; }

/* Tooltip: the email address on hover, confirmation after a copy. */
.social-btn::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translate(-50%, 3px);
  background: var(--fg); color: var(--bg);
  font-size: var(--step-1);
  padding: 5px 9px; border-radius: 5px;
  white-space: nowrap; pointer-events: none;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.social-btn::before {
  content: ""; position: absolute;
  bottom: calc(100% + 3px); left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--fg);
  opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
.social-btn[data-tip]:hover::after,
.social-btn[data-tip]:focus-visible::after,
.social-btn.is-copied::after {
  opacity: 1; transform: translate(-50%, 0);
}
.social-btn[data-tip]:hover::before,
.social-btn[data-tip]:focus-visible::before,
.social-btn.is-copied::before { opacity: 1; }

/* Copy state: briefly go accent-coloured and swap the icon. */
.social-btn.is-copied {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.social-btn .icon-check { display: none; }
.social-btn.is-copied .icon-check { display: block; }
.social-btn.is-copied .icon-mail  { display: none; }

@media (max-width: 560px) {
  .hero-actions { gap: 8px; }
  .social-row { padding-left: 0; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--step-1);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--fg-subtle); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--fg);
  border-color: var(--fg);
}

.btn-ghost { background: transparent; border-color: var(--border); color: var(--fg-muted); }
.btn-ghost:hover { color: var(--fg); background: var(--bg-hover); }

.btn-sm { padding: 6px 11px; font-size: var(--step-1); }

/* ============================================================
   Tags
   ============================================================ */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: var(--step-1);
  background: transparent;
  color: var(--tag-fg);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   Project card
   ============================================================ */
.project-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-card:hover {
  border-color: var(--accent);
}
.project-thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.project-thumb svg { width: 100%; height: 100%; }
.project-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.project-title-row { display: flex; align-items: baseline; gap: 10px; }
.project-card h3 { font-size: var(--step1); }
.project-year {
  margin-left: auto;
  font-size: var(--step-1);
  color: var(--fg-subtle);
  flex: none;
}
.project-desc {
  font-size: var(--step0);
  color: var(--fg-muted);
  line-height: 1.5;
  flex: 1;
}
.project-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: var(--step-1);
  color: var(--fg-subtle);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.project-meta b { color: var(--fg-muted); }

.project-sector {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: var(--step-1);
  color: var(--fg-muted);
  margin-top: -3px;
}
.nda-badge {
  font-size: var(--step-1);
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--tag-bg);
  color: var(--fg-subtle);
  border: 1px solid var(--border);
}

/* arch / role / impact — a compact spec table, the part that convinces. */
.project-specs {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 9px;
  margin-top: 1px;
  border-top: 1px solid var(--border);
  flex: 1;
}
.spec-row { display: grid; grid-template-columns: 46px 1fr; gap: 9px; align-items: baseline; }
.spec-label {
  font-size: var(--step-1);
  color: var(--accent);
}
.spec-value { font-size: var(--step-1); color: var(--fg-muted); line-height: 1.45; }

/* ============================================================
   Gallery (projects.html)
   ============================================================ */
.gallery-toolbar {
  position: sticky;
  top: 54px;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
  padding-block: 14px;
  margin-bottom: 28px;
}
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.search-field { position: relative; flex: 1 1 240px; min-width: 190px; }
.search-field svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--fg-subtle);
  pointer-events: none;
}
input[type="search"], select {
  font: inherit; font-size: var(--step0);
  color: var(--fg); background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="search"] {
  width: 100%; padding-left: 34px;
  -webkit-appearance: none; appearance: none;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="search"]:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; padding-right: 30px;
  -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.view-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-left: auto;
}
.view-switch button {
  font: inherit;
  font-size: var(--step-1);
  padding: 8px 13px;
  border: none;
  cursor: pointer;
  background: var(--bg-raised);
  color: var(--fg-muted);
  transition: all .15s;
}
.view-switch button + button { border-left: 1px solid var(--border); }
.view-switch button:hover { background: var(--bg-hover); color: var(--fg); }
.view-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }

.result-count {
  font-size: var(--step-1);
  color: var(--fg-subtle);
  margin-bottom: 20px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  padding-bottom: 80px;
}
.gallery-grid.is-compact { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.gallery-grid.is-compact .project-thumb { aspect-ratio: 2 / 1; }
.gallery-grid.is-compact .project-desc,
.gallery-grid.is-compact .project-meta { display: none; }
.gallery-grid.is-compact .project-body { padding: 12px 13px 13px; gap: 7px; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 70px 20px;
  color: var(--fg-subtle);
}
.empty-state p:first-child { font-size: var(--step2); color: var(--fg-muted); margin-bottom: 8px; }

/* ============================================================
   Work teaser (home) — a skills matrix, no project details
   ============================================================ */
.work-teaser {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Two columns so six groups don't push the next section below the fold.
   Groups have uneven chip counts, so columns are balanced by content
   rather than forced to equal height. */
.skill-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 30px;
}
@media (max-width: 760px) {
  .skill-matrix { grid-template-columns: 1fr; gap: 12px; }
}

.skill-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
/* Layout only — size, weight, tracking and colour belong to the theme. */
.skill-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* A hairline after the label keeps the groups legible without a full border. */
.skill-group-title::after {
  content: "";
  flex: 1; height: 0;
  border-top: 1px dashed var(--border);
}

.skill-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--fg-muted);
  font-size: var(--step-1);
  line-height: 1;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s, transform .15s;
}
.skill-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
/* Text-only chips have no mark to balance, so even out the padding. */
.skill-chip.is-textonly { padding-inline: 10px; }

.skill-icon {
  width: 15px;
  height: 15px;
  flex: none;
  /* TypeScript/JavaScript/HTML5/CSS3 marks knock their glyph out of a
     solid tile;
  this lets the chip background show through. */
  --icon-knockout: var(--bg-raised);
}

@media (max-width: 620px) {
  .work-teaser { padding: 18px; }
  .skill-chip { padding: 4px 9px 4px 7px; }
  .skill-icon { width: 14px; height: 14px; }
}

.teaser-foot {
  display: flex;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.teaser-foot .btn { margin-left: auto; }
@media (max-width: 620px) {
  .teaser-foot .btn { margin-left: 0; width: 100%; justify-content: center; }
}

/* ============================================================
   Experience
   ============================================================ */
.experience-list { display: flex; flex-direction: column; }
.xp-item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 24px;
  padding-block: 20px;
  border-top: 1px solid var(--border);
}
.xp-item:first-child { border-top: none; padding-top: 4px; }
.xp-period {
  font-size: var(--step-1);
  color: var(--fg-subtle);
  padding-top: 3px;
}
.xp-role { font-size: var(--step1); margin-bottom: 2px; }
.xp-company { color: var(--fg-muted); font-size: var(--step0); margin-bottom: 8px; }
.xp-company b { color: var(--fg); }
.xp-desc { color: var(--fg-muted); font-size: var(--step0); max-width: 66ch; margin-bottom: 10px; }
@media (max-width: 680px) {
  .xp-item { grid-template-columns: 1fr; gap: 8px; }
}

/* ============================================================
   Books — horizontal cards
   ============================================================ */
.book-list { display: flex; flex-direction: column; gap: 11px; }
.book-card {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 17px;
  align-items: start;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.book-card:hover { border-color: var(--accent); }
.book-cover {
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: var(--step2);
  color: var(--fg-subtle);
  overflow: hidden;
}
.book-main { min-width: 0; }
.book-title { font-size: var(--step1); margin-bottom: 2px; }
.book-author { color: var(--fg-muted); font-size: var(--step0); margin-bottom: 7px; }
.book-desc { color: var(--fg-muted); font-size: var(--step0); max-width: 72ch; margin-bottom: 9px; }
.book-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}
.book-status {
  font-size: var(--step-1);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  white-space: nowrap;
}
.book-status[data-status="reading"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.book-status[data-status="finished"] { border-color: color-mix(in srgb, var(--ok) 55%, transparent); color: var(--ok-ink); }
.book-rating { font-size: var(--step-1); color: var(--fg-subtle); white-space: nowrap; }

@media (max-width: 640px) {
  .book-card { grid-template-columns: 52px 1fr; gap: 16px; }
  .book-side {
    grid-column: 1 / -1; flex-direction: row;
    align-items: center; justify-content: flex-start;
    gap: 12px;
  }
}

/* ============================================================
   Hobby projects — skeleton
   ============================================================ */
.hobby-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.hobby-card {
  background: var(--bg-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
  transition: border-color .15s, background .15s;
}
.hobby-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.hobby-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: var(--step1);
}
.hobby-card h3 { font-size: var(--step1); }
.hobby-card p { font-size: var(--step0); color: var(--fg-muted); flex: 1; }
.hobby-status {
  font-size: var(--step-1);
  color: var(--fg-subtle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hobby-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-subtle);
}
.hobby-status[data-status="active"]::before { background: var(--ok); }
.hobby-status[data-status="paused"]::before { background: var(--warn); }

/* Skeleton shimmer placeholders */
.skel {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-line { height: 10px; }
.skel-line.w-70 { width: 70%; }
.skel-line.w-45 { width: 45%; }

/* ============================================================
   Page header (sub-pages)
   ============================================================ */
.page-header { padding-block: 56px 30px; }
.page-header h1 { font-size: var(--step4); margin-bottom: 12px; }
.page-header p { color: var(--fg-muted); max-width: 62ch; }
.breadcrumb {
  font-size: var(--step-1);
  color: var(--fg-subtle);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border-strong);
  padding-block: 24px;
  margin-top: 28px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  font-size: var(--step-1);
  color: var(--fg-subtle);
}
.footer-inner a { color: var(--fg-muted); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* Toast (CV download feedback) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  background: var(--fg);
  color: var(--bg);
  font-size: var(--step0);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 300;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

