/* fabio piparo — portfolio
   design language carried over from the under-current landing page:
   paper-gray ground, hairline 1px lines, 1px-gap grids, mono uppercase
   eyebrows, muted secondary text, no shadows, no radius, restrained hovers.
   every color/size decision lives in the tokens below — retheme here. */

:root {
  --bg: #e8eaec;
  --fg: #15171b;
  --muted: #71777e;
  --line: #cbced3;
  --card: #f6f7f8;
  --card-hover: #ffffff;
  --stage: #0a0a0b;
  --overlay: rgba(10, 10, 11, .92);
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --measure: 72ch;
  --page: 1080px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --fg: #e4e6e9;
    --muted: #8b9198;
    --line: #26292e;
    --card: #17181c;
    --card-hover: #1d1f24;
    --overlay: rgba(5, 5, 6, .94);
  }
}
/* explicit override hooks win over the media query in both directions */
:root[data-theme="light"] {
  --bg: #e8eaec; --fg: #15171b; --muted: #71777e; --line: #cbced3;
  --card: #f6f7f8; --card-hover: #ffffff; --overlay: rgba(10, 10, 11, .92);
}
:root[data-theme="dark"] {
  --bg: #101114; --fg: #e4e6e9; --muted: #8b9198; --line: #26292e;
  --card: #17181c; --card-hover: #1d1f24; --overlay: rgba(5, 5, 6, .94);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
}
/* full-bleed grids use 50vw math, which overshoots by the scrollbar width; clip it */
html { overflow-x: clip; }
body { font-size: .96rem; line-height: 1.75; }

a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line); transition: border-color .15s ease; }
a:hover { border-bottom-color: var(--fg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
::selection { background: rgba(255, 255, 0, .3); color: #000; }

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

.eyebrow {
  font-family: var(--mono); font-size: .67rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- shared page frame ---------- */
.wrap { max-width: var(--page); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }

.topbar {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: 1.1rem 0 1rem; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40; background: var(--bg);
}
/* full-bleed backdrop so bled grids scroll under the header, not beside it */
.topbar::before {
  content: ""; position: absolute; top: 0; bottom: 0; z-index: -1;
  left: calc(50% - 50vw); right: calc(50% - 50vw); background: var(--bg);
}
/* the header hairline runs to the viewport edges; the content stays in the column */
.topbar::after {
  content: ""; position: absolute; bottom: 0; height: 1px; background: var(--line);
  left: calc(50% - 50vw); right: calc(50% - 50vw);
}
.topbar .who { font-family: var(--mono); font-size: .8rem; letter-spacing: .06em; }
.topbar .who a, .topbar nav a { border-bottom: 0; }
.topbar nav { display: flex; gap: 1.4rem; font-family: var(--mono); font-size: .7rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--fg); }

footer {
  color: var(--muted); font-family: var(--mono); font-size: .7rem; text-align: center;
  line-height: 1.9; border-top: 1px solid var(--line);
  padding: 1.7rem 1rem 2.4rem; margin-top: 4rem;
}
footer b { color: var(--fg); font-weight: 600; }
footer a { color: var(--fg); border-bottom-color: var(--muted); }
footer .meta { margin-top: .7rem; opacity: .6; }

/* ---------- landing ---------- */
.masthead { padding: 2.6rem 0 2.2rem; display: grid; gap: 1rem; }
.masthead h1 {
  margin: 0; font-family: var(--mono); font-weight: 400; font-size: clamp(1.5rem, 4.5vw, 2.3rem);
  letter-spacing: .04em;
}
.masthead .tag { color: var(--muted); max-width: var(--measure); margin: 0; }
.masthead .links { display: flex; gap: 1.6rem; font-family: var(--mono); font-size: .74rem;
  letter-spacing: .1em; text-transform: uppercase; }

/* the editor's grid panel writes layout as custom properties on the grid:
   --card-min column density, --gap spacing (large gaps auto-clear the hairline
   fill via --grid-bg/--grid-border), --thumb-ar card image ratio */
.grid {
  display: grid; justify-content: center;
  /* --grid-cols carries the whole template when the editor sets one:
     "repeat(4, 1fr)" (columns mode) or "repeat(auto-fill, 340px)" (exact size) */
  grid-template-columns: var(--grid-cols, repeat(auto-fill, minmax(min(280px, 100%), 1fr)));
  gap: var(--gap, 1px); background: var(--grid-bg, var(--line));
  border: 1px solid var(--grid-border, var(--line));
  /* --bleed 0..1 breaks the grid out of the content column toward the viewport edges */
  margin-left: calc(var(--bleed, 0) * (50% - 50vw));
  margin-right: calc(var(--bleed, 0) * (50% - 50vw));
}
.card {
  background: var(--card); color: inherit; display: flex; flex-direction: column;
  border-bottom: 0; transition: background .15s ease;
}
.card:hover { background: var(--card-hover); }
.card .thumb { width: 100%; aspect-ratio: var(--thumb-ar, 16 / 10); object-fit: cover;
  /* per-card framing from the editor: --px/--py pan the crop, --tz zooms in */
  object-position: var(--px, 50%) var(--py, 50%);
  object-view-box: inset(var(--tz, 0%));
  border-bottom: 1px solid var(--line); background: var(--stage); }
.card .card-body { padding: 1.2rem 1.4rem 1.5rem; }
.card h2 { margin: .4rem 0 .45rem; font-size: 1.22rem; font-weight: 600; letter-spacing: -.01em; }
.card .sub { color: var(--muted); font-size: .85rem; line-height: 1.6; }
.card.text-only .card-body { padding-top: 1.5rem; }
.card.text-only::before { content: ""; display: block; border-bottom: 1px solid var(--line); }

.about { padding: 3.2rem 0 0; max-width: var(--measure); }
.about p { margin: .8rem 0; }
.clients { font-family: var(--mono); font-size: .74rem; letter-spacing: .08em;
  text-transform: lowercase; color: var(--muted); line-height: 2.1; }

.history { margin: 2.2rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.history li {
  display: grid; grid-template-columns: 7.5em 1fr auto; gap: 1rem; align-items: baseline;
  padding: .55rem 0; border-bottom: 1px solid var(--line);
  font-size: .87rem;
}
.history .co { font-weight: 600; }
.history .role { color: var(--muted); }
.history .yr { font-family: var(--mono); font-size: .7rem; color: var(--muted); letter-spacing: .08em; }
/* phones ignore desktop grid overrides */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
}

@media (max-width: 560px) {
  .history li { grid-template-columns: 1fr auto; }
  .history .role { grid-column: 1 / -1; padding-bottom: .2rem; }
}

/* ---------- project page ---------- */
.project { padding-top: 2.2rem; }
.project header.title-block { margin: 0 0 1.8rem; max-width: var(--measure); }
.project h1 { margin: .45rem 0 .8rem; font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.tldr { color: var(--muted); font-size: 1.02rem; margin: 0; }

.facts {
  display: flex; flex-wrap: wrap; gap: 1px; background: var(--line);
  border: 1px solid var(--line); margin: 2rem 0; padding: 0;
}
.facts div { background: var(--card); padding: .7rem 1.1rem .8rem; flex: 1 1 140px; }
.facts dt { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 .15rem; }
.facts dd { margin: 0; font-size: .85rem; }

.project section { margin: 2.6rem 0; }
.project section > h3 {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); font-weight: 400; margin: 0 0 1rem;
}
.project section > h3::before { content: "/ "; }
.project section p { max-width: var(--measure); margin: .8rem 0; }

.media { margin: 1.6rem 0; }
/* the editor's media panel writes sizing as custom properties on the figure:
   --w width, --ml/--mr alignment margins, --ar crop ratio (+ --fit cover), --px/--py pan */
figure.media { width: var(--w, auto); margin-left: var(--ml, 0); margin-right: var(--mr, 0); }
figure.media img, figure.media video {
  aspect-ratio: var(--ar, auto); object-fit: var(--fit, fill);
  object-position: var(--px, 50%) var(--py, 50%);
}
.media img, .media video { width: 100%; border: 1px solid var(--line); background: var(--stage); cursor: zoom-in; }
.media video[controls] { cursor: default; }
.media figcaption { font-family: var(--mono); font-size: .68rem; letter-spacing: .08em;
  color: var(--muted); padding-top: .5rem; }
/* a row groups whole figures side by side (each keeps its own caption);
   built and dissolved by the editor's media panel pair/unpair buttons */
.media-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1rem;
  align-items: start; width: var(--w, auto);
  margin: 1.6rem var(--mr, 0) 1.6rem var(--ml, 0); }
.media-row > figure.media { margin: 0; width: auto; }
/* vertical alignment of row children, set by the editor (data-ai on the row) */
.media-row[data-ai="center"] { align-items: center; }
.media-row[data-ai="end"] { align-items: end; }
.media-row[data-ai="stretch"] { align-items: stretch; }
.media-row[data-ai="stretch"] > figure.media { display: flex; flex-direction: column; }
.media-row[data-ai="stretch"] > figure.media img,
.media-row[data-ai="stretch"] > figure.media video { flex: 1 1 auto; min-height: 0; object-fit: cover; }
@media (max-width: 640px) { .media-row { grid-auto-flow: row; grid-auto-columns: unset; } }

.media.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line);
  border: 1px solid var(--line); }
.media.duo img, .media.duo video { border: 0; height: 100%; object-fit: cover; }
.media.duo figcaption { grid-column: 1 / -1; background: var(--bg); }
@media (max-width: 640px) { .media.duo { grid-template-columns: 1fr; } }

.techniques { display: flex; flex-wrap: wrap; gap: .45rem .5rem; padding: 0; margin: 1rem 0; list-style: none; }
.techniques li {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: lowercase;
  color: var(--muted); border: 1px solid var(--line); padding: .2rem .55rem; background: var(--card);
}

.credits { color: var(--muted); font-size: .85rem; max-width: var(--measure);
  border-top: 1px solid var(--line); padding-top: 1.2rem; white-space: pre-line; }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3.4rem;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.pager a { color: var(--muted); border-bottom: 0; }
.pager a:hover { color: var(--fg); }

/* ---------- lightbox ---------- */
#lightbox {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: .9rem;
  background: var(--overlay); padding: 2.2rem clamp(1rem, 4vw, 3rem);
  touch-action: pan-y;
}
#lightbox.active { display: flex; }
#lightbox .lb-stage { display: flex; align-items: center; justify-content: center;
  max-width: 100%; min-height: 0; flex: 1; }
#lightbox img, #lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; }
#lightbox .lb-caption { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  color: #9aa0a6; text-align: center; min-height: 1em; }
#lightbox button {
  position: absolute; background: transparent; border: 0; color: #9aa0a6; cursor: pointer;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  padding: 1rem; transition: color .15s ease;
}
#lightbox button:hover { color: #fff; }
#lightbox .lb-close { top: .4rem; right: .6rem; }
#lightbox .lb-prev { left: .2rem; top: 50%; transform: translateY(-50%); }
#lightbox .lb-next { right: .2rem; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) { #lightbox .lb-prev, #lightbox .lb-next { display: none; } }

/* hero actions: prominent open/play links right under a project hero */
.hero-actions { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 0 0 2.2rem; }
.hero-actions a { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: .7rem;
  background: var(--card); color: var(--fg); text-decoration: none;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  padding: 1.05rem 1.2rem; text-align: center; }
.hero-actions a:hover { background: var(--card-hover); }
.hero-actions a[target="_blank"]::before { content: "\2197\00a0"; font-size: 1.5em; line-height: 1; }
.hero-actions img { width: 72px; height: auto; display: block; border: 1px solid var(--line); }
@media (max-width: 640px) { .hero-actions { flex-direction: column; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
