/* Adriel Ventura, engineering portfolio
   Editorial: warm paper, near-black ink, one muted ink-blue accent.
   Source Serif 4 for major headings, Source Sans 3 for everything else,
   monospace for notation; Courier Prime for controls (typed labels).
   Rules in DESIGN.md. */

/* 1. Tokens -------------------------------------------------------------- */
:root {
  --paper: #f7f4ee;
  --paper-2: #efebe3;      /* table heads, quiet fills */
  --plate: #2b2a27;        /* backdrop for CAD renders only */
  --ink: #1c1b19;
  --ink-2: #45423c;        /* body copy */
  --muted: #625e55;        /* metadata; 5.6:1 on paper */
  --rule: #d8d2c6;
  --rule-strong: #b9b2a4;
  --accent: #2d4a6b;       /* links; 8.4:1 on paper */
  --accent-hover: #1b3350;

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Source Sans Pro", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --mark: #f1e3a4;         /* :target highlight */
  --type: "Courier Prime", "Courier New", Courier, monospace;   /* buttons and action links */

  --text: 1.125rem;        /* 18 px body */
  --small: 1rem;           /* 16 px metadata, captions; never smaller */
  --measure: 40rem;        /* reading column */
  --wide: 70rem;           /* figures, project list */
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --space: clamp(3.5rem, 8vw, 6rem);   /* between sections */
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-2);
  font: 400 var(--text)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; color: var(--ink); }

h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); line-height: 1.1; }
h2 { font-size: clamp(1.75rem, 3.4vw, 2.25rem); line-height: 1.15; }
h3 { font-family: var(--sans); font-size: 1.25rem; font-weight: 600; line-height: 1.3; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

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

img { display: block; max-width: 100%; height: auto; }

ul, ol { margin: 0; padding-left: 1.25rem; }
li + li { margin-top: 0.35rem; }

strong { color: var(--ink); font-weight: 600; }

.mono, code { font-family: var(--mono); font-size: 0.92em; }

[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: 0.75rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; color: var(--paper); }

.wrap { width: min(var(--wide), 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { max-width: var(--measure); }

.section { padding-block: var(--space) 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 2rem; padding-bottom: 0.9rem; margin-bottom: 2rem; border-bottom: 1px solid var(--ink); }
.section-head p { margin: 0; color: var(--muted); font-size: var(--small); }

.meta { color: var(--muted); font-size: var(--small); }

/* 3. Header -------------------------------------------------------------- */
.site-header { border-bottom: 1px solid var(--rule); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  min-height: 3.75rem;
  padding-block: 0.5rem;
}

.site-name { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.site-name:hover { color: var(--ink); }

.site-nav { display: flex; flex-wrap: wrap; gap: 0 1.25rem; margin: 0; padding: 0; list-style: none; }
.site-nav li + li { margin: 0; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-2);
  font-size: var(--small);
  text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; }

/* 4. Introduction -------------------------------------------------------- */
.intro { padding-block: clamp(2.5rem, 6vw, 4.5rem) 0; }
.intro h1 { margin-bottom: 1rem; }
.intro .lede { font-size: clamp(1.2rem, 2.2vw, 1.375rem); line-height: 1.5; color: var(--ink); max-width: 38rem; }
.intro-links { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.intro-links li + li { margin: 0; }
.intro-links a { display: inline-flex; align-items: center; min-height: 44px; }

/* 5. Selected work ------------------------------------------------------- */
.feature {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}

.plate { background: var(--plate); }
.plate img { margin-inline: auto; }

.feature-media { margin: 0; }
.feature-media .viewer > img { padding: 6%; }
.spin-toggle { margin: 0.5rem 0 0 -0.35rem; }

.feature h3 { font-family: var(--serif); font-size: clamp(1.5rem, 2.6vw, 1.875rem); line-height: 1.2; margin-bottom: 0.4rem; }
.feature h3 a { color: var(--ink); text-decoration: none; }
.feature h3 a:hover { text-decoration: underline; }

.facts { margin: 1.25rem 0 0; }
.facts div { padding: 0.75rem 0; border-top: 1px solid var(--rule); }
.facts dt { font-size: var(--small); font-weight: 600; color: var(--ink); }
.facts dd { margin: 0.15rem 0 0; }

.more { display: inline-flex; align-items: center; min-height: 44px; margin-top: 0.75rem; font: 400 var(--small)/1.2 var(--type); }
.more::after { content: "\00a0\2192"; content: "\00a0\2192" / ""; }

.work-list { list-style: none; margin: clamp(2.5rem, 6vw, 4rem) 0 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.work-list > li {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 0.5rem 2.5rem;
  margin: 0;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.work-list h3 { margin-bottom: 0.25rem; }
.work-list .meta { margin: 0; }
.work-list .body p { max-width: var(--measure); }
.work-list figure { margin: 1rem 0 0; max-width: 24rem; }

/* 6. Figures ------------------------------------------------------------- */
figure { margin: 0; }
figcaption { margin-top: 0.6rem; color: var(--muted); font-size: var(--small); line-height: 1.5; }
figcaption b { color: var(--ink); font-weight: 600; }

.figure-white img { background: #fff; border: 1px solid var(--rule); }
.chapter .wrap > figure { margin-block: 2rem; }
.figure-wide { max-width: 46rem; }
.sources-note { margin-top: 1.5rem; }

.figure-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; margin-block: 2rem; }

/* 7. Tables -------------------------------------------------------------- */
.table-scroll { overflow-x: auto; margin-block: 1.5rem; }
.table-scroll:focus-visible { outline-offset: 0; }

table { width: 100%; border-collapse: collapse; font-size: var(--small); }
caption { caption-side: top; text-align: left; padding-bottom: 0.5rem; color: var(--muted); }
th, td { padding: 0.6rem 0.75rem 0.6rem 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
thead th { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--ink); }
tbody th { font-weight: 600; color: var(--ink); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
tr.chosen th, tr.chosen td { background: var(--paper-2); }
tr.chosen th { padding-left: 0.5rem; }
td.assumed { color: var(--accent); font-weight: 600; }

/* 8. Experience ---------------------------------------------------------- */
.roles { list-style: none; margin: 0; padding: 0; }
.roles > li {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  gap: 0.25rem 2.5rem;
  margin: 0;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.roles > li:first-child { padding-top: 0; }
.role-when { color: var(--muted); font-size: var(--small); }
.role-when span { display: block; }
.roles h3 { margin-bottom: 0.1rem; }
.roles .org { margin-bottom: 0.5rem; color: var(--ink-2); }
.roles ul { max-width: var(--measure); }

.subhead { margin: 3rem 0 1rem; font-size: 1.25rem; }

.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 3rem; }
.columns h3 { margin-bottom: 0.75rem; }

/* 9. Press --------------------------------------------------------------- */
.press { list-style: none; margin: 0; padding: 0; }
.press > li { margin: 0; padding: 1.25rem 0; border-bottom: 1px solid var(--rule); max-width: 48rem; }
.press > li:first-child { padding-top: 0; }
.press h3 { font-size: 1.125rem; margin-bottom: 0.2rem; }

/* 10. About + contact ---------------------------------------------------- */
.about { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 20rem); gap: 2rem 4rem; align-items: start; }
.contact-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.contact-list li { margin: 0; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.contact-list span { display: block; color: var(--muted); font-size: var(--small); }
.contact-list a { overflow-wrap: anywhere; }

/* 11. Footer ------------------------------------------------------------- */
.site-footer { margin-top: var(--space); padding-block: 2rem 2.5rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: var(--small); }
.site-footer h2 { font-family: var(--sans); font-size: var(--small); font-weight: 600; color: var(--ink); margin-bottom: 0.5rem; }
.site-footer ul { max-width: 52rem; }

/* 12. Case study --------------------------------------------------------- */
.case-head { padding-block: clamp(2rem, 5vw, 3.5rem) 0; }
.crumb { margin-bottom: 1.5rem; font-size: var(--small); }
.case-head h1 { max-width: 26ch; margin-bottom: 1rem; }
.case-head .lede { font-size: clamp(1.2rem, 2.2vw, 1.375rem); line-height: 1.5; color: var(--ink); max-width: 40rem; }

.case-top { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: clamp(1.5rem, 4vw, 3.5rem); margin-top: 2.5rem; align-items: start; }

.facts-box { margin: 0; border-top: 1px solid var(--ink); }
.facts-box div { padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.facts-box dt { color: var(--muted); font-size: var(--small); }
.facts-box dd { margin: 0; color: var(--ink); }

.toc { margin-top: 2.5rem; padding: 1rem 0; border-block: 1px solid var(--rule); }
.toc ol { display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin: 0; padding: 0; list-style: none; }
.toc li + li { margin: 0; }
.toc a { display: inline-flex; min-height: 44px; align-items: center; font-size: var(--small); }

.chapter { padding-top: var(--space); }
.chapter > .wrap > h2 { margin-bottom: 1.25rem; }
.prose { max-width: var(--measure); }
.prose ul, .prose ol { margin-bottom: 1rem; }

.equation { margin: 1.5rem 0; padding: 1rem 1.25rem; background: var(--paper-2); border-left: 2px solid var(--ink); font-family: var(--mono); font-size: 1rem; color: var(--ink); overflow-x: auto; max-width: var(--measure); }
.equation span { display: block; margin-top: 0.35rem; color: var(--muted); }

.path { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0; margin: 1.5rem 0; padding: 0; list-style: none; font-size: var(--small); }
.path li { margin: 0; display: flex; align-items: center; }
.path li + li::before { content: "\2192"; margin: 0 0.6rem; color: var(--muted); }
.path span { padding: 0.4rem 0.7rem; border: 1px solid var(--rule-strong); background: #fff; color: var(--ink); }
.path small { display: block; color: var(--muted); font-size: var(--small); }

.note { margin: 1.5rem 0; padding: 1rem 1.25rem; border: 1px solid var(--rule-strong); background: #fff; max-width: var(--measure); }

.files { list-style: none; margin: 1.5rem 0 0; padding: 0; border-top: 1px solid var(--rule-strong); max-width: var(--measure); }
.files li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; margin: 0; border-bottom: 1px solid var(--rule); }
.files a { display: inline-flex; align-items: center; min-height: 44px; }
.files span { display: inline-flex; align-items: center; color: var(--muted); font-size: var(--small); }

/* 3D viewer: static render first; the canvas replaces it on request */
.viewer { position: relative; aspect-ratio: 1 / 0.93; overflow: hidden; }
.viewer > img { width: 100%; height: 100%; object-fit: contain; padding: 7%; }
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.viewer canvas:active { cursor: grabbing; }
.viewer.is-live > img { visibility: hidden; }
.viewer canvas:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }

/* Controls read like typed labels: [Angled]  [x] Section cut.
   The brackets are drawn with CSS and hidden from screen readers. */
.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.35rem;
  border: 0;
  background: none;
  color: var(--ink);
  font: 400 var(--small)/1.2 var(--type);
  letter-spacing: 0.01em;
  cursor: pointer;
}
.button::before { content: "["; content: "[" / ""; color: var(--muted); }
.button::after { content: "]"; content: "]" / ""; color: var(--muted); }
.button:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.button:active { color: var(--accent); }
.button[aria-pressed]::before { content: "[ ]\00a0"; content: "[ ]\00a0" / ""; }
.button[aria-pressed]::after { content: none; }
.button[aria-pressed="true"]::before { content: "[x]\00a0"; content: "[x]\00a0" / ""; color: var(--ink); }

.viewer-controls { display: flex; flex-wrap: wrap; gap: 0 0.75rem; margin: 0.5rem 0 0 -0.35rem; }
.viewer-status { margin: 0.5rem 0 0; color: var(--muted); font-size: var(--small); }
.open-3d { width: fit-content; margin: 0.5rem 0 0 -0.35rem; text-align: left; }

/* 12b. Typewriter layer --------------------------------------------------
   Everything that is a label, date, number or control is "typed" in
   Courier Prime; reading text stays in Source Sans, headings in Source Serif.
   Ideas: Courier Prime (quoteunquoteapps/CourierPrime, OFL), the typed
   section marks and :target highlight in riggraz/no-style-please (MIT),
   captions set beside the figure they explain, as in edwardtufte/tufte-css (MIT).
   No code copied. */
.site-nav a,
.meta,
.section-head p,
.facts dt,
.facts-box dt,
.role-when,
.crumb,
.toc a,
caption,
thead th,
figcaption b,
.files span,
.site-footer h2 {
  font-family: var(--type);
  font-weight: 400;
  letter-spacing: 0.01em;
}
.facts dt, .facts-box dt, figcaption b, thead th { color: var(--ink); }
.facts dt::after, .facts-box dt::after { content: ":"; content: ":" / ""; }

/* Case-study chapters get typed numbers: 01, 02, ... (hidden from screen readers). */
main { counter-reset: chapter; }
.chapter { counter-increment: chapter; }
.chapter > .wrap > h2::before {
  content: counter(chapter, decimal-leading-zero) "\2003";
  content: counter(chapter, decimal-leading-zero) "\2003" / "";
  font: 400 1rem/1 var(--type);
  color: var(--muted);
  vertical-align: 0.35em;
}
.toc ol { counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a::before { content: counter(toc, decimal-leading-zero) "\00a0"; content: counter(toc, decimal-leading-zero) "\00a0" / ""; color: var(--muted); }

/* Jumping to a chapter marks it, like a highlighter on a typed page. */
.chapter:target > .wrap > h2 { background: linear-gradient(transparent 55%, var(--mark) 55%); }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 13. Responsive --------------------------------------------------------- */
@media (max-width: 860px) {
  .feature, .case-top, .about { grid-template-columns: 1fr; }
  /* One column: keep the render from filling a whole tablet screen */
  .feature-media .viewer, .case-top .viewer { aspect-ratio: 4 / 3; }
  .work-list > li, .roles > li { grid-template-columns: 1fr; }
  .work-list figure { max-width: 100%; }
}

@media (max-width: 600px) {
  :root { --text: 1.0625rem; }
  .site-header .wrap { padding-block: 0.4rem; }
  .site-nav { gap: 0 1rem; }
  .figure-row, .columns { grid-template-columns: 1fr; }
  td.num { white-space: normal; }
  /* Tools table: one block per tool instead of three narrow columns */
  .tools thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tools tr { display: block; padding: 0.75rem 0; border-bottom: 1px solid var(--rule); }
  .tools th, .tools td { display: block; padding: 0; border: 0; }
  .tools td:last-child { color: var(--muted); }
}

/* 14. Motion ------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* 15. Print -------------------------------------------------------------- */
@media print {
  @page { margin: 15mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .skip-link, .site-nav, .toc, .viewer-controls, .viewer-status, .open-3d, .viewer canvas, .site-footer ul, .no-print { display: none !important; }
  .plate { background: #fff; }
  .section, .chapter { padding-top: 1.25rem; }
  .feature, .case-top, .about, .figure-row, .columns { display: block; }
  .work-list > li, .roles > li, tr, figure { break-inside: avoid; }
  .work-list > li, .roles > li { display: block; padding: 0.6rem 0; }
  .feature-media, .work-list figure { display: none; }
  figure img { max-height: 75mm; width: auto; }
  a { color: #000; }
}
