/* =========================================================
   Thành Marine — personal site
   Static, dependency-free, light/dark, VI/EN
   ========================================================= */

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper: #f7f5ef;
  --paper-raised: #fffdf8;
  --paper-tint: #efece2;
  --ink: #0c1b26;
  --ink-soft: #3d515c;
  --muted: #687b85;
  --line: #dcd6c8;
  --line-strong: #c6beab;
  --teal: #0b6b68;
  --teal-soft: rgba(11, 107, 104, 0.09);
  --signal: #b9541f;
  --signal-soft: rgba(185, 84, 31, 0.1);
  --grid: rgba(12, 27, 38, 0.06);
  --shadow: 0 24px 60px rgba(12, 27, 38, 0.08);
  --shadow-soft: 0 10px 28px rgba(12, 27, 38, 0.06);

  --panel: #0c1b26;
  --panel-ink: #f4f6f1;
  --panel-muted: #a9b8bd;
  --panel-line: rgba(255, 255, 255, 0.15);
  --panel-accent: #f0a06a;

  --footer: #071117;
  --footer-ink: #e9efeb;
  --footer-muted: #93a6ab;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 14px;
  --shell: 1120px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0b141a;
  --paper-raised: #0f1d24;
  --paper-tint: #0e1a21;
  --ink: #edf2ee;
  --ink-soft: #bfcccd;
  --muted: #8ea1a6;
  --line: #23363e;
  --line-strong: #344a52;
  --teal: #67d8cf;
  --teal-soft: rgba(103, 216, 207, 0.1);
  --signal: #ef9b64;
  --signal-soft: rgba(239, 155, 100, 0.1);
  --grid: rgba(237, 242, 238, 0.05);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.28);

  color-scheme: dark;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--teal); color: var(--paper); }

img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }

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

.shell {
  width: min(var(--shell), 100% - 56px);
  margin-inline: auto;
}

.mono {
  font-family: var(--mono);
  font-size: 0.78em;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}
.skip-link:focus { transform: none; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

@supports (backdrop-filter: blur(12px)) {
  .site-header {
    background: color-mix(in srgb, var(--paper) 84%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
  }
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 8px 30px rgba(12, 27, 38, 0.04);
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-mark { width: 36px; height: 36px; border-radius: 9px; }
.brand-text {
  font-family: var(--serif);
  font-size: 1.14rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-text em { font-style: normal; color: var(--teal); }

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.2vw, 28px);
  margin-left: auto;
}
.site-nav a {
  position: relative;
  font-size: 14.5px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 0;
  transition: color 0.18s ease;
  white-space: nowrap;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--teal);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.site-nav a:hover,
.site-nav a.is-active { color: var(--ink); }
.site-nav a:hover::after,
.site-nav a.is-active::after { transform: scaleX(1); }

.header-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.icon-button,
.lang-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}
.icon-button:hover,
.lang-button:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
  background: var(--paper-raised);
}
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

.lang-button { width: auto; min-width: 42px; padding: 0 10px; }
.lang-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.menu-button {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.menu-button span {
  display: block;
  height: 1.5px;
  background: var(--ink-soft);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.menu-button[aria-expanded="true"] span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.menu-button[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-button[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 132px 0 96px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse 62% 70% at 82% 18%, var(--teal-soft), transparent 62%),
    var(--paper);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 75% 80% at 62% 38%, #000 10%, transparent 78%);
  mask-image: radial-gradient(ellipse 75% 80% at 62% 38%, #000 10%, transparent 78%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr);
  align-items: center;
  gap: clamp(36px, 5vw, 72px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 24px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--signal);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
  flex-shrink: 0;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.7rem, 5.6vw, 5rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--ink);
  text-wrap: balance;
}
h1 .accent {
  color: var(--teal);
  font-style: italic;
  font-weight: 500;
}

.lede {
  max-width: 53ch;
  margin: 26px 0 32px;
  font-size: 18px;
  line-height: 1.7;
  color: var(--ink-soft);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 21px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.button:hover svg { transform: translateX(3px); }

.button-primary { background: var(--ink); color: var(--paper); }
.button-primary:hover { background: var(--teal); color: var(--paper); }

.button-ghost { border-color: var(--line-strong); color: var(--ink); }
.button-ghost:hover { border-color: var(--ink); background: var(--paper-raised); }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}
.hero-meta li { display: inline-flex; align-items: center; gap: 8px; }
.hero-meta a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.hero-meta a:hover { color: var(--teal); border-color: var(--teal); }
.hero-meta .mono { font-size: 10.5px; color: var(--ink-soft); }

/* ---------- Hero figure ---------- */

.hero-figure { justify-self: end; width: 100%; max-width: 450px; }

.chart {
  position: relative;
  padding: 14px;
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.chart::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  pointer-events: none;
}

.chart-tag {
  position: absolute;
  top: -11px;
  left: 22px;
  z-index: 2;
  padding: 4px 9px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
}

.chart-corner {
  position: absolute;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-color: var(--signal);
  border-style: solid;
  opacity: 0.85;
}
.chart-corner-tr { top: 10px; right: 10px; border-width: 1.5px 1.5px 0 0; }
.chart-corner-bl { bottom: 10px; left: 10px; border-width: 0 0 1.5px 1.5px; }

.chart svg { width: 100%; height: auto; }

.chart-grid path { fill: none; stroke: var(--line); stroke-width: 1; opacity: 0.75; }
.chart-ring { fill: none; stroke: var(--line-strong); stroke-width: 1.1; }
.chart-ring-faint { stroke: var(--line-strong); stroke-dasharray: 2 7; opacity: 0.85; }
.chart-ticks path { fill: none; stroke: var(--muted); stroke-width: 1.2; opacity: 0.8; }
.chart-compass text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  fill: var(--muted);
}
.chart-needle { fill: var(--ink); stroke: var(--ink); stroke-width: 1; opacity: 0.92; }
.chart-needle-accent { fill: var(--signal); stroke: var(--signal); opacity: 1; }
.chart-hub { fill: var(--paper-raised); stroke: var(--ink); stroke-width: 1.5; }
.chart-route {
  fill: none;
  stroke: var(--signal);
  stroke-width: 1.4;
  stroke-dasharray: 3 6;
  opacity: 0.8;
}
.chart-point { fill: var(--paper-raised); stroke: var(--signal); stroke-width: 1.6; }
.chart-point-accent { fill: var(--signal); }
.chart-note {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  fill: var(--muted);
}
.chart-note-small { font-size: 8px; opacity: 0.75; }

.chart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  padding: 10px 6px 4px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--muted);
}
.chart-footer .mono { font-size: 9.5px; color: var(--signal); }

/* ---------- Sections ---------- */

.section {
  padding: 96px 0;
  border-bottom: 1px solid var(--line);
}
.section-tint { background: var(--paper-tint); }

.section-head {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  column-gap: 36px;
  row-gap: 14px;
  margin-bottom: 50px;
}
.kicker {
  grid-column: 1;
  align-self: start;
  display: flex;
  gap: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker span:first-child { color: var(--signal); }

.section-head h2 {
  grid-column: 2;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.4vw, 2.75rem);
  line-height: 1.14;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;
}
.section-intro {
  grid-column: 2;
  max-width: 58ch;
  font-size: 16px;
  color: var(--muted);
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(280px, 0.82fr);
  gap: clamp(36px, 5vw, 68px);
  align-items: start;
}

.prose p {
  margin-bottom: 18px;
  font-size: 17.5px;
  line-height: 1.78;
  color: var(--ink-soft);
}
.prose p:last-child { margin-bottom: 0; }

.prose blockquote {
  margin-top: 32px;
  padding-left: 22px;
  border-left: 2px solid var(--signal);
}
.prose blockquote p {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.32rem;
  line-height: 1.5;
  color: var(--ink);
}

.fact-card {
  padding: 28px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.fact-card h3 {
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--signal);
}
.fact-card dl > div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}
.fact-card dl > div:last-child { border-bottom: 0; }
.fact-card dt {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 3px;
}
.fact-card dd { font-size: 14px; line-height: 1.5; color: var(--ink); }
.identity-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- Projects ---------- */

.project-list { border-top: 1px solid var(--line-strong); }

.project {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 24px;
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}
.project-index {
  padding-top: 7px;
  font-size: 11px;
  color: var(--signal);
}
.project-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.project h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.62rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  transition: color 0.18s ease;
}
.project:hover h3 { color: var(--teal); }
.project-body > p {
  max-width: 68ch;
  margin: 10px 0 16px;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ink-soft);
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
}
.tags li {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fineprint {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-top: 26px;
  font-size: 13.5px;
  color: var(--muted);
}
.fineprint a {
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--teal) 40%, transparent);
}
.fineprint a:hover { border-bottom-color: var(--teal); }

/* ---------- Principles ---------- */

.principle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line-strong);
}
.principle {
  padding: 30px 10px 32px 0;
  border-bottom: 1px solid var(--line);
}
.principle:nth-child(odd) {
  padding-right: 46px;
  border-right: 1px solid var(--line);
}
.principle:nth-child(even) { padding-left: 46px; }
.principle-number {
  font-size: 10px;
  color: var(--signal);
}
.principle h3 {
  margin: 12px 0 8px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
}
.principle p:last-child {
  max-width: 46ch;
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- Stack ---------- */

.stack-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--line-strong);
}
.stack-group h3 {
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
}
.stack-group ul { list-style: none; }
.stack-group li {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  color: var(--ink-soft);
  transition: color 0.18s ease;
}
.stack-group li:hover { color: var(--ink); }

/* ---------- Contact ---------- */

.contact-section { padding: 96px 0; }

.contact-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(280px, 0.78fr);
  gap: clamp(36px, 5vw, 64px);
  padding: clamp(32px, 5vw, 64px);
  overflow: hidden;
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.contact-panel::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 560px;
  height: 560px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}
.contact-panel::after {
  content: "";
  position: absolute;
  top: -30%;
  right: 2%;
  width: 420px;
  height: 420px;
  border: 1px dashed rgba(255, 255, 255, 0.09);
  border-radius: 50%;
  pointer-events: none;
}
.contact-copy { position: relative; z-index: 1; }
.contact-panel .kicker {
  border-top-color: var(--panel-line);
  color: var(--panel-muted);
}
.contact-panel .kicker span:first-child { color: var(--panel-accent); }
.contact-panel h2 {
  max-width: 16ch;
  margin: 18px 0 18px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 3.9vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--panel-ink);
  text-wrap: balance;
}
.contact-copy > p {
  max-width: 52ch;
  font-size: 16px;
  line-height: 1.7;
  color: var(--panel-muted);
}
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}
.button-signal { background: var(--panel-accent); color: #1a1206; }
.button-signal:hover { background: #ffb784; }
.button-outline-light {
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--panel-ink);
}
.button-outline-light:hover { border-color: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.06); }

.contact-card {
  position: relative;
  z-index: 1;
  align-self: start;
  padding: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
}
.contact-card dl > div {
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.contact-card dl > div:first-child { padding-top: 0; }
.contact-card dl > div:last-child { border-bottom: 0; padding-bottom: 0; }
.contact-card dt {
  margin-bottom: 3px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--panel-muted);
}
.contact-card dd { font-size: 14px; color: var(--panel-ink); overflow-wrap: anywhere; }
.contact-card a { color: var(--panel-ink); text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, 0.25); }
.contact-card a:hover { color: var(--panel-accent); border-bottom-color: var(--panel-accent); }
.contact-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--panel-muted);
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 42px 0 38px;
  background: var(--footer);
  color: var(--footer-ink);
}
.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px 32px;
  align-items: start;
}
.footer-brand p { font-size: 13.5px; }
.footer-note { margin-top: 3px; font-size: 12px; color: var(--footer-muted); }
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: flex-end;
  font-size: 12.5px;
}
.footer-nav a { color: var(--footer-muted); text-decoration: none; transition: color 0.18s ease; }
.footer-nav a:hover { color: var(--footer-ink); }
.footer-updated {
  grid-column: 1 / -1;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 10px;
  color: var(--footer-muted);
}

/* ---------- Legal pages ---------- */

.legal-page { background: var(--paper); }
.legal-main { padding: 72px 0 96px; }
.legal-head {
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 40px;
}
.legal-head .kicker { max-width: 220px; border-top: 0; padding-top: 0; }
.legal-head h1 {
  margin: 14px 0 12px;
  font-size: clamp(2.2rem, 4.4vw, 3.4rem);
}
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 13px;
  color: var(--muted);
}
.legal-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.legal-toc {
  position: sticky;
  top: 100px;
  padding: 20px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.legal-toc p {
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
}
.legal-toc ol { padding-left: 18px; }
.legal-toc li { margin: 7px 0; font-size: 12.5px; line-height: 1.45; }
.legal-toc a { color: var(--muted); text-decoration: none; }
.legal-toc a:hover { color: var(--teal); }

.legal-content { max-width: 72ch; }
.legal-content section { margin-bottom: 36px; scroll-margin-top: 100px; }
.legal-content h2 {
  margin-bottom: 12px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
}
.legal-content h3 {
  margin: 20px 0 8px;
  font-size: 15px;
  font-weight: 600;
}
.legal-content p,
.legal-content li {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
}
.legal-content p + p { margin-top: 12px; }
.legal-content ul { margin: 10px 0 10px 20px; }
.legal-content li { margin: 6px 0; }
.legal-content a { color: var(--teal); }
.legal-content .notice {
  margin: 18px 0;
  padding: 16px 18px;
  background: var(--teal-soft);
  border-left: 2px solid var(--teal);
  border-radius: 0 8px 8px 0;
}
.legal-content .notice p { color: var(--ink); }
.legal-content table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 14px;
}
.legal-content th,
.legal-content td {
  padding: 9px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  color: var(--ink-soft);
}
.legal-content th { background: var(--paper-tint); font-weight: 600; color: var(--ink); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.back-link:hover { color: var(--teal); }

/* ---------- 404 ---------- */

.error-page {
  min-height: calc(100vh - 78px);
  display: grid;
  place-items: center;
  padding: 64px 0;
  background:
    radial-gradient(ellipse 60% 60% at 50% 30%, var(--teal-soft), transparent 70%),
    var(--paper);
}
.error-inner { max-width: 560px; text-align: center; }
.error-code {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--signal);
}
.error-inner h1 {
  margin: 16px 0 14px;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  letter-spacing: -0.03em;
}
.error-inner p { margin-bottom: 26px; color: var(--muted); }
.error-inner .button { margin: 0 5px; }

/* ---------- Reveal ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.js .reveal.is-visible { opacity: 1; transform: none; }
.project.reveal:nth-child(2) { transition-delay: 0.06s; }
.project.reveal:nth-child(3) { transition-delay: 0.12s; }
.principle.reveal:nth-child(2) { transition-delay: 0.05s; }
.principle.reveal:nth-child(3) { transition-delay: 0.1s; }
.principle.reveal:nth-child(4) { transition-delay: 0.15s; }
.stack-group.reveal:nth-child(2) { transition-delay: 0.05s; }
.stack-group.reveal:nth-child(3) { transition-delay: 0.1s; }
.stack-group.reveal:nth-child(4) { transition-delay: 0.15s; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .hero { padding-top: 110px; }
  .hero-grid { gap: 40px; }
  .contact-panel { padding: 48px 40px; }
}

@media (max-width: 900px) {
  .menu-button { display: flex; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 8px 0 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 30px rgba(12, 27, 38, 0.07);
  }
  .site-nav.is-open { display: flex; }
  .site-nav a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
  }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav a::after { display: none; }
}

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-figure { justify-self: start; max-width: 460px; margin-top: 8px; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .fact-card { max-width: 560px; }
  .contact-panel { grid-template-columns: minmax(0, 1fr); }
  .contact-panel h2 { max-width: 20ch; }
  .contact-card { max-width: 560px; }
}

@media (max-width: 760px) {
  .shell { width: min(var(--shell), 100% - 40px); }
  .section { padding: 72px 0; }
  .section-head {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 16px;
    margin-bottom: 38px;
  }
  .section-head h2,
  .section-intro,
  .kicker { grid-column: 1; }
  .section-head h2 { margin-top: 2px; }
  .principle-grid { grid-template-columns: minmax(0, 1fr); }
  .principle,
  .principle:nth-child(odd),
  .principle:nth-child(even) {
    padding: 26px 0 28px;
    border-right: 0;
  }
  .stack-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 26px; }
  .contact-section { padding: 72px 0; }
  .contact-panel { padding: 34px 26px; border-radius: 16px; }
  .legal-body { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .legal-toc { position: static; }
  .footer-inner { grid-template-columns: minmax(0, 1fr); }
  .footer-nav { justify-content: flex-start; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .shell { width: min(var(--shell), 100% - 32px); }
  .header-inner { min-height: 68px; gap: 12px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-text { font-size: 1.02rem; }
  .hero { padding: 96px 0 64px; }
  .eyebrow { font-size: 10.5px; letter-spacing: 0.1em; }
  h1 { font-size: clamp(2.3rem, 9vw, 3.1rem); }
  .lede { margin: 22px 0 26px; font-size: 16px; }
  .hero-actions { gap: 10px; }
  .button { padding: 12px 17px; font-size: 14px; }
  .hero-meta { flex-direction: column; align-items: flex-start; gap: 9px; margin-top: 30px; }
  .project { grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 24px 0; }
  .project-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .project h3 { font-size: 1.4rem; }
  .project-body > p { font-size: 14.5px; }
  .stack-grid { grid-template-columns: minmax(0, 1fr); }
  .contact-panel { padding: 30px 22px; }
  .contact-actions .button { flex: 1 1 auto; }
  .legal-main { padding: 48px 0 72px; }
  .legal-head h1 { font-size: 2rem; }
  .error-inner .button { display: flex; margin: 10px 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .status-dot { box-shadow: none; }
}

@media print {
  .site-header,
  .site-footer,
  .hero-figure,
  .hero-actions,
  .contact-actions,
  .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .section { padding: 24px 0; border-color: #ccc; }
  a { text-decoration: underline; }
}
