/* Mateo Perez Barrio — portfolio
   Sizes follow the Figma frames (1852 wide, 1552 content) and scale down fluidly. */

:root {
  --ink: #5c5c5c;
  --mid: #818181;
  --soft: #a8a8a8;
  --divider: #cccccc;
  --line: #e8e8e8;
  --placeholder: #f1f1f1;
  --bg: #ffffff;

  --display: clamp(48px, 5.18vw, 96px);
  --statement: clamp(23px, 2.16vw, 40px);
  --title: clamp(21px, 1.62vw, 30px);
  --brand: clamp(19px, 1.51vw, 28px);
  --nav: clamp(16px, 1.19vw, 22px);
  --body: clamp(16px, 1.19vw, 22px);
  --label: clamp(14px, 1.08vw, 20px);
  --meta: clamp(13px, 0.97vw, 18px);

  --gutter: clamp(20px, 8.1vw, 150px);
  --content: 1552px;
  --gap: clamp(16px, 1.73vw, 32px);
  --photo-gap: clamp(8px, 1.3vw, 24px);
  --section: clamp(72px, 6.9vw, 128px);
  --label-col: clamp(160px, 19.4vw, 360px);

  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 300;
  font-size: var(--body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
h1, h2, h3, p, figure, ul { margin: 0; padding: 0; }
ul { list-style: none; }

.skip { position: absolute; left: -9999px; top: 0; background: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

.wrap { width: 100%; max-width: calc(var(--content) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- header / nav ---------- */
.site-header { padding-top: clamp(24px, 3.5vw, 64px); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.brand { font-size: var(--brand); font-weight: 300; line-height: 1.2; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: clamp(12px, 1.08vw, 20px); font-size: var(--nav); font-weight: 400; }
.nav a { color: var(--soft); transition: color .15s; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav .sep { width: 2px; height: .82em; background: var(--divider); }

main { padding: clamp(96px, 10.8vw, 200px) 0 clamp(120px, 13vw, 240px); }
.stack > * + * { margin-top: var(--section); }

/* ---------- type ---------- */
.display { font-size: var(--display); font-weight: 100; line-height: 1.2; letter-spacing: -0.005em; }
.statement { font-size: var(--statement); font-weight: 300; line-height: 1.35; }
.title { font-size: var(--title); font-weight: 400; line-height: 1.2; }
.body { font-size: var(--body); font-weight: 300; line-height: 1.55; color: var(--mid); }
.label { font-size: var(--label); font-weight: 400; line-height: 1.2; color: var(--soft); }
.meta { font-size: var(--meta); font-weight: 400; line-height: 1.2; color: var(--soft); }
.hero .body { margin-top: 24px; max-width: 1000px; }

/* ---------- home ---------- */
.home { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; padding: 48px 0; }
.home h1 { font-size: clamp(46px, 5.12vw, 95px); font-weight: 100; line-height: 1.19; }
.home .nav { font-size: clamp(18px, 1.48vw, 27.5px); gap: clamp(14px, 1.3vw, 24px); }
.home .nav a { color: var(--ink); }
.home .nav a:hover { color: var(--soft); }
.home .nav .sep { background: var(--mid); height: .84em; }

/* ---------- two-column sections ---------- */
.section { display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); column-gap: var(--gap); }
.section > .label { padding-top: 28px; }
.section > .content { border-top: 1px solid var(--line); padding-top: 28px; min-width: 0; }
.section > .content.rows { padding-top: 0; border-top: 0; }
.prose { max-width: 840px; }
.prose p + p { margin-top: 1em; }
.quote { margin-top: 40px; max-width: 1000px; }

/* list rows (experience, archive) */
.row { display: grid; grid-template-columns: clamp(120px, 11vw, 200px) minmax(0, 1.4fr) minmax(0, 1fr); column-gap: clamp(20px, 1.73vw, 32px); align-items: baseline; padding: 28px 0; border-top: 1px solid var(--line); }
.rows .row:last-child { border-bottom: 1px solid var(--line); }
.row .when { font-size: var(--body); font-weight: 400; color: var(--soft); line-height: 1.2; }
.row .what .desc { margin-top: 6px; max-width: 640px; }
.row .detail { color: var(--mid); }

/* facts */
.facts { display: flex; flex-wrap: wrap; gap: 24px clamp(24px, 3vw, 72px); margin-top: 48px; }
.fact .label { font-size: var(--meta); }
.fact .value { font-size: var(--body); font-weight: 400; margin-top: 8px; line-height: 1.2; }

/* ---------- about ---------- */
.intro { display: grid; grid-template-columns: minmax(0, 0.745fr) minmax(0, 1fr); gap: clamp(32px, 6.3vw, 116px) clamp(32px, 8.6vw, 160px); align-items: start; }
.portrait { background: var(--placeholder); aspect-ratio: 608 / 760; overflow: hidden; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.bio .body { margin-top: 32px; }
.bio .body + .body { margin-top: 24px; }
.skills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px var(--gap); }
.skills h3 { font-size: var(--body); font-weight: 400; line-height: 1.2; margin-bottom: 12px; }
.skills li { color: var(--mid); line-height: 1.6; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px var(--gap); margin: 48px 0; }
.card-img { aspect-ratio: 365 / 456; background: var(--placeholder); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card h3 { font-size: var(--body); font-weight: 400; margin-top: 20px; line-height: 1.2; }
.card p { margin-top: 8px; }
.links { display: flex; flex-wrap: wrap; gap: 16px 40px; margin-top: 32px; font-weight: 400; }
.links a:hover { color: var(--soft); }

/* ---------- projects ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(48px, 4.3vw, 80px) var(--gap); margin-top: 32px; }
.project-card .cover { aspect-ratio: 760 / 507; background: var(--placeholder); overflow: hidden; }
.project-card .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.project-card:hover .cover img { transform: scale(1.02); }
.project-card .info { margin-top: 28px; }
.project-card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.project-card .info .body { margin-top: 12px; }
.project-card .info .meta { margin-top: 12px; }
.archive { margin-top: 32px; }

/* ---------- project detail ---------- */
.back { font-size: var(--meta); color: var(--soft); font-weight: 400; }
.back:hover { color: var(--ink); }
.kicker { margin-top: 40px; }
.case-title { margin-top: 16px; }
.case-summary { margin-top: 24px; max-width: 1000px; }
.case-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px var(--gap); margin-top: clamp(48px, 4.3vw, 80px); padding-top: 28px; border-top: 1px solid var(--line); }
.figure-img { background: var(--placeholder); overflow: hidden; }
.figure-img img { width: 100%; height: 100%; object-fit: cover; }
.ratio-169 { aspect-ratio: 16 / 9; }
.ratio-43 { aspect-ratio: 4 / 3; }
.ratio-45 { aspect-ratio: 4 / 5; }
figcaption { display: flex; justify-content: space-between; gap: 16px; margin-top: 12px; font-size: var(--meta); color: var(--ink); line-height: 1.3; }
figcaption span:last-child { color: var(--soft); white-space: nowrap; }
.two-up { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.three-up { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px var(--gap); margin-top: 48px; }
.step .title { margin-top: 12px; }
.step .body { margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px var(--gap); margin-top: 48px; }
.stat .display { line-height: 1.1; }
.stat .body { margin-top: 8px; }
.next { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-top: 40px; border-top: 1px solid var(--line); }
.next .display { margin-top: 8px; transition: color .15s; }
.next .arrow { font-size: var(--display); font-weight: 100; line-height: 1; transition: transform .2s; }
.next:hover .display { color: var(--mid); }
.next:hover .arrow { transform: translateX(8px); }

/* ---------- photography ---------- */
.filters { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.filters ul { display: flex; flex-wrap: wrap; gap: 10px clamp(18px, 1.73vw, 32px); }
.filters button { font: inherit; font-size: var(--nav); font-weight: 400; color: var(--soft); background: none; border: 0; padding: 0; cursor: pointer; }
.filters button:hover, .filters button[aria-pressed="true"] { color: var(--ink); }
.gallery-section { margin-top: clamp(64px, 6.5vw, 120px); }
.gallery-section[hidden] { display: none; }
.gallery-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 40px; }
.justified { --rh: clamp(150px, 20.5vw, 380px); display: flex; flex-wrap: wrap; gap: var(--photo-gap); }
.justified::after { content: ""; flex-grow: 999999; }
.justified a { position: relative; display: block; flex-grow: calc(var(--a) * 100); flex-basis: calc(var(--a) * var(--rh)); background: var(--placeholder); overflow: hidden; }
.justified a i { display: block; padding-bottom: calc(100% / var(--a)); }
.justified img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .3s; }
.justified a:hover img { opacity: .9; }
.justified.laid::after { display: none; }
.justified.laid a { flex: none; }
.justified.laid a i { display: none; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(255, 255, 255, .98); display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; grid-template-rows: 72px minmax(0, 1fr) 56px; }
.lightbox[hidden] { display: none; }
.lightbox figure { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: center; min-height: 0; }
.lightbox img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.lightbox button { font: inherit; background: none; border: 0; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox button:hover { color: #000; }
.lb-close { grid-column: 3; grid-row: 1; font-size: 40px; font-weight: 300; }
.lb-prev, .lb-next { grid-row: 2; font-size: 40px; font-weight: 300; }
.lb-prev { grid-column: 1; }
.lb-next { grid-column: 3; }
.lb-count { grid-column: 2; grid-row: 3; text-align: center; font-size: var(--meta); color: var(--soft); align-self: center; }
body.lb-open { overflow: hidden; }

/* ---------- footer ---------- */
.site-footer .wrap > div { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; padding: 40px 0 clamp(32px, 3.2vw, 60px); border-top: 1px solid var(--line); }
.signature { display: flex; align-items: center; gap: 16px; font-size: var(--meta); color: var(--soft); font-weight: 400; }
.signature img { width: 32px; height: 40px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 12px 40px; font-size: var(--meta); font-weight: 400; }
.foot-links a:hover { color: var(--soft); }

/* ---------- 404 ---------- */
.notfound { min-height: 60vh; display: flex; flex-direction: column; justify-content: center; gap: 24px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .row { grid-template-columns: 140px minmax(0, 1fr); }
  .row .detail { grid-column: 2; margin-top: 4px; }
  .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .section { grid-template-columns: minmax(0, 1fr); }
  .section > .label { padding-top: 0; margin-bottom: 16px; }
  .intro { grid-template-columns: minmax(0, 1fr); }
  .portrait { max-width: 420px; }
  .row { grid-template-columns: minmax(0, 1fr); padding: 22px 0; }
  .row .when { font-size: var(--meta); margin-bottom: 8px; }
  .row .detail { grid-column: 1; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card-img { aspect-ratio: 4 / 3; }
  .projects-grid { grid-template-columns: minmax(0, 1fr); }
  .case-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-up, .three-up, .steps { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .stat .display { font-size: 40px; }
  .stat .body { font-size: 14px; }
  .facts { gap: 20px 32px; margin-top: 32px; }
  .lightbox { grid-template-columns: 0 minmax(0, 1fr) 0; grid-template-rows: 56px minmax(0, 1fr) 64px; }
  .lb-close { grid-column: 2; justify-self: end; padding: 0 16px; }
  .lb-prev, .lb-next { grid-row: 3; font-size: 32px; }
  .lb-prev { grid-column: 2; justify-self: start; padding: 0 24px; }
  .lb-next { grid-column: 2; justify-self: end; padding: 0 24px; }
}
