/* ---------------------------------------------------------
   Martín Amaya · Portfolio
   Design system: off-white minimalism, editorial type,
   fixed left sidebar nav, dark-scrim hover reveal on cards.
--------------------------------------------------------- */

:root {
  --bg: #f6f5f5;
  --panel: #ffffff;
  --ink: #131311;
  --muted: #6f6c67;
  --border: #dedbd5;
  --scrim: rgba(30, 28, 26, 0.94);
  --scrim-text: #f3f1ee;
  --accent: #131311;
  --sidebar-w: 300px;
  --gap: 10px;
  --content-max: 1180px;
  --radius: 2px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, -apple-system, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

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

.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3, h4 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.2rem, 4.4vw, 3.8rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 2rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; color: var(--ink); font-weight: 300; }
p.lede { font-size: 1.15rem; color: var(--muted); max-width: 640px; font-weight: 300; }

/* ---------------- Layout shell ---------------- */

.layout {
  display: flex;
  min-height: 100vh;
}

#site-sidebar { flex: 0 0 var(--sidebar-w); }

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 56px 64px 96px;
}

/* Left padding is 0: the sidebar already contributes --gap via its own
   right-side padding, so adding another --gap here would double the
   left gutter versus the top/right/bottom gutters. */
.main--flush { padding: var(--gap) var(--gap) var(--gap) 0; }

.main-narrow { max-width: var(--content-max); margin: 0 auto; }

/* ---------------- Sidebar (injected by nav.js) ---------------- */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  z-index: 40;
  background: var(--bg);
  overflow-y: auto;
}

.sidebar-box {
  background: var(--panel);
  padding: 16px 20px;
}

.sidebar-box.name-box {
  flex: 0 0 auto;
}

.sidebar-box.nav-box {
  flex: 0 0 auto;
  padding: 8px;
}

.sidebar-box.heading-box {
  flex: 1 1 auto;
  padding: 24px 22px;
}

.brand {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0;
  color: var(--ink);
}

.sidebar-nav { list-style: none; margin: 0; padding: 0; }

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-radius: 0;
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sidebar-nav a:hover { color: var(--ink); }
.sidebar-nav a.active { color: var(--ink); border-bottom-color: var(--ink); }

.section-heading {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-size: clamp(1.7rem, 2.6vw, 2.3rem);
  color: var(--ink);
  margin: 0;
}

.section-intro {
  margin: 16px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  font-weight: 300;
  max-width: 46ch;
}

.sidebar-toggle { display: none; }

/* ---------------- Project grid + hover reveal ---------------- */

.project-grid {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* All hero/card-thumbnail source images are standardized to the same
   2796x1804 shot dimensions, so every card is guaranteed the same
   size and objects sit centered, matching the Wix reference's uniform
   grid. object-fit:cover only ever crops a hair of margin since the
   input images already share this exact aspect ratio. */
.project-card {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--panel);
  aspect-ratio: 2796 / 1804;
}

.project-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: saturate(0.93) contrast(1.03);
  transition: transform 0.5s ease;
}

.project-card:hover img { transform: scale(1.04); }

.card-index {
  position: absolute;
  top: 14px; left: 14px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #fff;
  background: rgba(0,0,0,0.45);
  padding: 3px 8px;
  border-radius: var(--radius);
  letter-spacing: 0.08em;
}

/* Hover caption: top-left, sized to actually read at a glance, not a
   small strip you have to hunt for at the bottom of the image. */
.card-caption {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  color: var(--scrim-text);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.project-card:hover .card-caption,
.project-card:focus-visible .card-caption {
  opacity: 1;
  transform: translateY(0);
}

/* Same size as the project page's own <h1>, so the hover preview reads
   at the same weight as the page it links to. */
.card-caption h3 { color: #fff; margin-bottom: 10px; font-size: clamp(2.2rem, 4.4vw, 3.8rem); line-height: 1.1; }
.card-caption .date { font-size: 13px; color: #c9c6c0; margin-bottom: 12px; font-family: "IBM Plex Mono", monospace; letter-spacing: 0.06em; }
.card-caption p { color: #d8d5cf; font-size: 16px; margin-bottom: 14px; max-width: 560px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
}

/* muted-tag variant for use on light backgrounds (project pages) */
.tag-light {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--ink);
  display: inline-block;
}

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

.hero {
  position: relative;
  overflow: hidden;
  height: calc(100vh - 2 * var(--gap));
}

.hero img { width: 100%; height: 100%; object-fit: cover; filter: saturate(0.92) contrast(1.04); }

/* Plain hero: image only, no caption, ever (used on the name-click landing page) */
.hero--plain { height: calc(100vh - 2 * var(--gap)); }

/* ---------------- Project detail pages ---------------- */

.project-header { margin-bottom: 36px; }
.project-header .eyebrow { margin-bottom: 10px; }
.project-header .meta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.section { margin: 56px 0; max-width: var(--content-max); }
.section-title { border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 20px; }
.section-title .eyebrow { margin-bottom: 6px; }

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: start;
}

/* ---------------- Content grid ----------------
   The structural system every project page's body content snaps to.
   Pick 2 or 4 columns per section; text and figures span whole
   column-counts (span-1, span-2, span-3, span-4) so nothing floats
   free of the grid. No visible grid lines, this is purely alignment. */
.content-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap) 24px;
  align-items: start;
  margin: 24px 0;
}

.content-grid--2 { grid-template-columns: repeat(2, 1fr); }

.content-grid .span-1 { grid-column: span 1; }
.content-grid .span-2 { grid-column: span 2; }
.content-grid .span-3 { grid-column: span 3; }
.content-grid .span-4 { grid-column: 1 / -1; }

/* Every image/video in a content-grid gets the same fixed aspect ratio
   and crops (object-fit: cover, centered) to fill it. Because height is
   then purely a function of a cell's width, two cells of equal span
   automatically end up the exact same height, with no empty space and
   no dependency on sibling content, whether that's a photo next to a
   photo, a photo next to a video, or a lone image with nothing beside
   it. span-4 (always full-bleed/solo in a 4-col grid) uses the site's
   wide hero ratio instead of the narrower default. */
.content-grid figure,
.content-grid .figure { margin: 0; max-width: none; }
.content-grid img,
.content-grid video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: center; border-radius: var(--radius); }
/* Engineering drawings, schematics, and CAD renders must never be
   cropped, even inside a content-grid: unlike photos, losing part of
   a dimensioned drawing or a CAD model loses real information. Mark
   these `.figure--doc` and they revert to natural aspect ratio, no
   object-fit. Keep drawings that need to sit in a symmetrical grid
   together in their own content-grid (all figure--doc, similar source
   aspect ratios) rather than mixed with cropped photo cells. */
.content-grid .figure--doc img,
.content-grid .figure--doc video,
.content-grid img.figure--doc,
.content-grid video.figure--doc { aspect-ratio: auto; object-fit: contain; height: auto; }
.content-grid .span-4 img,
.content-grid .span-4 video { aspect-ratio: 2796 / 1804; }
.content-grid figcaption { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

@media (max-width: 860px) {
  .content-grid,
  .content-grid--2 { grid-template-columns: 1fr; }
  .content-grid .span-1,
  .content-grid .span-2,
  .content-grid .span-3,
  .content-grid .span-4 { grid-column: 1 / -1; }
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gap);
  margin: 20px 0;
  align-items: start;
}

.media-grid--2 { grid-template-columns: repeat(2, 1fr); }

/* Every image on this site shows at its natural aspect ratio: never
   cropped, never letterboxed. Capped by max-height (not a fixed box)
   so tall photos stay compact instead of forcing a long scroll. */
.media-grid img, .media-grid video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 260px;
  display: block;
  border-radius: var(--radius);
}
.media-grid--doc img {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px;
}

/* Default figure: photographic, natural aspect ratio, compact. */
.figure { margin: 20px 0; max-width: 720px; }
.figure img, .figure video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 380px;
  border-radius: var(--radius);
  display: block;
}
.figure figcaption { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* Dramatic dark-vignette treatment for a hero-style shot (matches the
   dark shaded look on the source presentation's own hero image) */
.figure--shaded { position: relative; }
.figure--shaded::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.55) 100%);
  border-radius: var(--radius);
}
.figure--shaded img { filter: saturate(0.9) contrast(1.08) brightness(0.96); }

/* Full-bleed variant for hero-style lead photos on project pages.
   Same standardized 2796x1804 aspect ratio as the portfolio-grid card
   thumbnails, since it's frequently the exact same source image
   displayed at a different size, not a different crop. */
.figure--wide { margin: 20px 0; max-width: none; width: 100%; aspect-ratio: 2796 / 1804; overflow: hidden; }
.figure--wide img {
  width: 100%; height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.93) contrast(1.03);
}

/* Document/diagram variant: a light panel frame around the image,
   still shown at its natural aspect ratio, never letterboxed. Applies
   whether figure--doc wraps the img (.figure--doc img) or sits
   directly on a bare <img class="figure--doc"> inside a content-grid
   (img.figure--doc), so every engineering drawing gets the same white
   panel frame regardless of which markup pattern placed it. */
.figure--doc { max-width: none; }
.figure--doc img,
img.figure--doc,
video.figure--doc {
  max-height: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px;
  box-sizing: border-box;
}
.figure--small { max-width: 420px; }
.figure--small img { max-height: 260px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin: 24px 0; }
.stat { min-width: 0; }
@media (max-width: 640px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat .num { font-family: "IBM Plex Mono", monospace; font-size: 1.6rem; font-weight: 700; display: block; }
.stat .label { font-size: 12px; color: var(--muted); }

.doc-link-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.03em;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.doc-link:hover { border-color: var(--ink); background: #fff; }

model-viewer {
  width: 100%;
  height: 420px;
  background: #d9d6cf;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.model-caption { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* ---------------- Tables (BOM / resume) ---------------- */

table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
tfoot td { font-weight: 700; border-bottom: none; border-top: 2px solid var(--ink); }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
}
.btn:hover { background: #000; }
.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--ink); }

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

.contact-list { list-style: none; padding: 0; margin: 24px 0; max-width: 560px; }
.contact-list li { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 0; border-bottom: 1px solid var(--border); }
.contact-list .k { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.contact-list .v { font-size: 1.05rem; }

/* ---------------- Status badge (WIP) ---------------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #c98a2b; }

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

.page-footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

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

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  #site-sidebar { flex-basis: auto; }
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px;
    gap: 10px;
    overflow: visible;
  }
  .sidebar-box.name-box { flex: 1 1 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; overflow: hidden; }
  .sidebar-box.name-box .brand { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-box.nav-box { display: none; }
  .sidebar-box.heading-box { display: none; }
  .sidebar.nav-open .sidebar-box.nav-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: fixed;
    top: var(--mobile-nav-top, 56px); left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: var(--bg);
    padding: 8px 24px;
    overflow-y: auto;
  }
  .sidebar.nav-open .sidebar-nav a {
    font-size: 20px;
    padding: 16px 4px;
  }
  .sidebar-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--border);
    padding: 8px 12px;
    background: none;
    cursor: pointer;
  }
  .main { padding: 32px 20px 64px; }
  .main--flush { padding: var(--gap); }
  .two-col { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .hero, .hero--plain { height: calc(70vh - 2 * var(--gap)); }
}

/* ---------------- Scroll reveal ---------------- */

.reveal {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* Staggered reveal delays for grid children (project cards, media grids) */
.project-grid .project-card:nth-child(1),
.media-grid > *:nth-child(1) { transition-delay: 0s; }
.project-grid .project-card:nth-child(2),
.media-grid > *:nth-child(2) { transition-delay: 0.04s; }
.project-grid .project-card:nth-child(3),
.media-grid > *:nth-child(3) { transition-delay: 0.08s; }
.project-grid .project-card:nth-child(4),
.media-grid > *:nth-child(4) { transition-delay: 0.12s; }
.project-grid .project-card:nth-child(5) { transition-delay: 0.16s; }
.project-grid .project-card:nth-child(6) { transition-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------------- Math / code blocks ---------------- */

pre.math-block, pre.code-block {
  margin: 0;
  padding: 18px 20px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
}
pre.math-block { color: var(--ink); }
pre.code-block { color: #e8e5df; background: #1e1c1a; border-radius: var(--radius); }

code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9em;
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ---------------- Embedded documents ---------------- */

.doc-embed { margin: 24px 0; }
.doc-embed embed, .doc-embed object {
  width: 100%;
  height: 640px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.doc-embed .doc-embed-caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.doc-embed .doc-embed-caption a { text-decoration: underline; text-underline-offset: 2px; }
