/* ============================================================================
   Alexander Sousa — portfolio
   Plain and quiet: small type, generous white space, almost no chrome.
   The project screenshots carry the visual weight; the page stays out of the way.
   ========================================================================= */

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Fragment links land below the sticky header rather than under it. The bar
     wraps to two rows on narrow screens, so the offset is larger there. */
  scroll-padding-top: 7.25rem;
}
@media (min-width: 520px) { html { scroll-padding-top: 5rem; } }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
/* height:auto is load-bearing — without it the width/height attributes win and
   aspect-ratio is ignored, which stretches images. */
img { max-width: 100%; display: block; height: auto; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* --- Tokens --------------------------------------------------------------- */
:root {
  --paper:        #FFFFFF;
  --paper-sunk:   #F7F6F3;
  --ink:          #23262B;
  --ink-soft:     #55595F;
  --ink-muted:    #85898F;
  --rule:         #E6E4DE;
  --accent:       #1A1C1F;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --ease:   cubic-bezier(.22, .7, .18, 1);
  --shadow: 0 16px 32px -20px rgba(24, 26, 30, .38);

  --wide:    920px;
  --measure: 34rem;
  --gutter:  clamp(1.25rem, 5vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #17181B;
    --paper-sunk: #1E2023;
    --ink:        #E7E4DD;
    --ink-soft:   #AFACA5;
    --ink-muted:  #85827B;
    --rule:       #2C2E32;
    --accent:     #F3F1EB;
    --shadow:     0 16px 32px -18px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  --paper:      #17181B;
  --paper-sunk: #1E2023;
  --ink:        #E7E4DD;
  --ink-soft:   #AFACA5;
  --ink-muted:  #85827B;
  --rule:       #2C2E32;
  --accent:     #F3F1EB;
  --shadow:     0 16px 32px -18px rgba(0, 0, 0, .7);
}

/* --- Base ----------------------------------------------------------------- */
body {
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: var(--gutter); }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.25;
  color: var(--accent);
  letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.0625rem; }

p + p { margin-top: 1rem; }

a {
  color: var(--accent); text-decoration: underline;
  text-underline-offset: 2px; text-decoration-thickness: 1px;
  transition: color .2s ease, text-decoration-color .2s ease, text-decoration-thickness .18s ease;
}
a:hover { text-decoration-thickness: 2px; }

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

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--ink); color: var(--paper); padding: .6rem 1rem; z-index: 200; }

.rule { border: 0; border-top: 1px solid var(--rule); margin-block: clamp(2.5rem, 6vw, 4rem); }

/* --- Header --------------------------------------------------------------- */
.site-header {
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-sunk);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: box-shadow .3s ease, background-color .3s ease;
}
/* Once the page has moved, the bar lifts off it. */
.site-header.is-stuck { box-shadow: var(--shadow); }

.scroll-progress { position: absolute; inset: auto 0 -1px 0; height: 2px; pointer-events: none; overflow: hidden; }
.scroll-progress span {
  display: block; height: 100%; width: 100%; background: var(--accent); opacity: .5;
  transform: scaleX(0); transform-origin: left center;
}

.site-header__inner { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: baseline; justify-content: space-between; }
.brand { font-family: var(--serif); font-size: 1rem; color: var(--ink); text-decoration: none; font-weight: 500; transition: color .2s ease; }
.brand:hover { color: var(--accent); }

.site-header__right { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }

.nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.nav a {
  position: relative; font-size: .8125rem; color: var(--ink-soft); text-decoration: none;
  padding-bottom: 3px; transition: color .22s ease;
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px;
  background: currentColor; transform: scaleX(0); transform-origin: left center;
  transition: transform .3s var(--ease);
}
.nav a:hover, .nav a:focus-visible,
.nav a[aria-current="page"], .nav a.is-active { color: var(--accent); }
.nav a:hover::after, .nav a:focus-visible::after,
.nav a[aria-current="page"]::after, .nav a.is-active::after { transform: scaleX(1); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 1.9rem; height: 1.9rem; border-radius: 999px; color: var(--ink-soft);
  transition: color .2s ease, background-color .25s ease, transform .25s var(--ease);
}
.theme-toggle:hover { color: var(--accent); background: var(--rule); transform: rotate(-14deg); }
.theme-toggle:active { transform: scale(.88) rotate(-14deg); }
.theme-toggle .icon { width: 1.05rem; height: 1.05rem; }
.theme-toggle .icon--sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon--sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon--moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon--sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon--moon { display: none; }

/* --- Hero: photo left, words right ---------------------------------------- */
.hero { padding-block: clamp(1.5rem, 4vw, 3rem) 0; }
.hero__grid { display: grid; gap: clamp(1.5rem, 4vw, 3rem); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 720px) { .hero__grid { grid-template-columns: 15rem minmax(0, 1fr); } }

.portrait img { width: 100%; aspect-ratio: 1 / 1.12; object-fit: cover; border-radius: 2px; }
@media (max-width: 719px) { .portrait { max-width: 11rem; } }

.hero h1 { margin-bottom: 1rem; }
.hero__body { max-width: var(--measure); }
.hero__actions { margin-top: 1.5rem; }

.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--sans); font-size: .875rem; font-weight: 500; color: var(--ink);
  text-decoration: none; border: 1px solid var(--rule); border-radius: 3px;
  padding: .7rem 1.15rem;
  transition: transform .24s var(--ease), border-color .24s ease, color .24s ease,
              background-color .24s ease, box-shadow .28s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow); }
@media (hover: hover) { .btn:hover { transform: translateY(-2px); } }
.btn:active { transform: translateY(0) scale(.985); box-shadow: none; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn--primary:hover { color: var(--paper); opacity: .9; }

/* --- Experience list (About) ---------------------------------------------- */
.roles { margin-bottom: 1.5rem; }
.role + .role { margin-top: 1.25rem; }
.roles dt { margin-bottom: .25rem; }
.role__org { font-weight: 600; color: var(--ink); font-size: .875rem; }
.role__meta { font-size: .78rem; color: var(--ink-muted); }
.roles dd { margin: 0; font-size: .875rem; }

/* --- Section heads -------------------------------------------------------- */
.section { padding-block: clamp(1rem, 3vw, 2rem); }
.section__head { text-align: center; margin-bottom: clamp(1.75rem, 4vw, 2.75rem); }
.section__head p { font-size: .8125rem; color: var(--ink-muted); margin-top: .5rem; }
.section__head--left { text-align: left; }

/* --- Image cards ---------------------------------------------------------- */
.cards { display: grid; gap: clamp(1.5rem, 4vw, 2.5rem); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 660px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card__media {
  border: 1px solid var(--rule); border-radius: 2px; overflow: hidden; background: var(--paper-sunk);
  transition: border-color .3s ease, box-shadow .35s ease;
}
.card__media img {
  width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top center;
  transition: transform .55s var(--ease);
}

.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-top: .9rem; }
.card__title { font-family: var(--sans); font-size: .9375rem; font-weight: 500; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.card__arrow { color: var(--ink-muted); flex: none; transition: transform .3s var(--ease), color .25s ease; }
.card__text { font-size: .8125rem; color: var(--ink-muted); margin-top: .3rem; line-height: 1.6; }

/* The whole card swells slightly on hover, the screenshot inside it a little
   more, so the frame reads as a window the image is pressing against. Motion
   comes from four custom properties (see "Interaction" at the foot of this
   file) so hover states and the on-scroll reveal can never fight over
   `transform`. */
.card {
  display: block; text-decoration: none;
  transform: translate(var(--shift, 0px), calc(var(--rise, 0px) + var(--enter, 0px)))
             scale(var(--pop, 1));
  transition: transform .4s var(--ease), opacity .5s ease;
}
@media (hover: hover) {
  .card:hover { --pop: 1.02; --rise: -4px; }
  .card:hover .card__media img { transform: scale(1.06); }
}
.card:focus-visible { --pop: 1.02; --rise: -4px; }
.card:hover .card__media, .card:focus-visible .card__media { border-color: var(--ink-muted); box-shadow: var(--shadow); }
.card:hover .card__title, .card:focus-visible .card__title { text-decoration-thickness: 2px; }
.card:hover .card__arrow, .card:focus-visible .card__arrow { transform: translateX(5px); color: var(--accent); }
.card:active { --pop: .995; --rise: -1px; }

/* --- Plain project list --------------------------------------------------- */
.list { border-top: 1px solid var(--rule); }
.list__row {
  display: grid; gap: .15rem .75rem; padding: .95rem 0;
  border-bottom: 1px solid var(--rule); text-decoration: none;
  grid-template-columns: minmax(0, 1fr) auto;
  transform: translate(var(--shift, 0px), calc(var(--rise, 0px) + var(--enter, 0px)));
  transition: transform .28s var(--ease), background-color .28s ease, opacity .5s ease;
}
.list__row:hover, .list__row:focus-visible { background: var(--paper-sunk); --shift: 4px; }
.list__row:hover .list__title { text-decoration-thickness: 2px; }
.list__title { font-size: .875rem; font-weight: 500; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.list__text { font-size: .8125rem; color: var(--ink-muted); grid-column: 1 / -1; line-height: 1.6; }
.status { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); white-space: nowrap; }
.status--live { color: var(--accent); }

/* --- About / contact ------------------------------------------------------ */
.prose { max-width: var(--measure); }
.contact__list { margin-top: 1.25rem; }
.contact__list li + li { margin-top: .55rem; }
.contact__list .k { font-weight: 600; color: var(--ink); font-size: .875rem; }

/* --- Footer --------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: clamp(3rem, 7vw, 5rem); padding-block: 1.75rem 3rem; }
.site-footer__inner { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; justify-content: space-between; }
.site-footer p, .site-footer a { font-size: .78rem; color: var(--ink-muted); }
.site-footer a { position: relative; text-decoration: none; padding-bottom: 2px; transition: color .2s ease; }
.site-footer a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left center;
  transition: transform .3s var(--ease);
}
.site-footer a:hover, .site-footer a:focus-visible { color: var(--accent); }
.site-footer a:hover::after, .site-footer a:focus-visible::after { transform: scaleX(1); }
.site-footer nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* --- Case study ----------------------------------------------------------- */
.back { margin-bottom: 1.75rem; }

.case-hero { padding-block: clamp(1.5rem, 4vw, 2.5rem) 0; }
.case-hero__eyebrow { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: .75rem; }
.case-hero h1 { margin-bottom: .5rem; }
.case-hero__sub { font-size: .875rem; color: var(--ink-muted); }
.case-hero__tag { margin-top: 1rem; max-width: var(--measure); }
.case-hero__actions { margin-top: 1.5rem; }

.meta { display: grid; gap: 1rem 2rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); margin-top: 2rem; padding-block: 1.25rem; border-block: 1px solid var(--rule); }
.meta dt { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: .2rem; }
.meta dd { font-size: .8125rem; color: var(--ink); line-height: 1.55; }

.shot { margin-top: 2rem; }
.shot img { display: block; width: 100%; border: 1px solid var(--rule); border-radius: 2px; }
.shot figcaption { font-size: .75rem; color: var(--ink-muted); margin-top: .55rem; }

/* The screenshot doubles as the "open project" link, so it gets the same
   swelling hover as the homepage cards (.card__media above) — the border and
   clipping move to the link so the image can scale inside it. */
.shot__link {
  display: block; overflow: hidden; border: 1px solid var(--rule); border-radius: 2px;
  transition: border-color .3s ease, box-shadow .35s ease;
}
.shot__link img { border: none; border-radius: 0; transition: transform .55s var(--ease); }
@media (hover: hover) {
  .shot__link:hover img, .shot__link:focus-visible img { transform: scale(1.06); }
}
.shot__link:hover, .shot__link:focus-visible { border-color: var(--ink-muted); box-shadow: var(--shadow); }

.figs { display: flex; flex-wrap: wrap; gap: 2rem; margin-top: 2rem; }
.fig__v { font-family: var(--serif); font-size: 1.5rem; color: var(--ink); line-height: 1.1; }
.fig__l { font-size: .75rem; color: var(--ink-muted); margin-top: .25rem; max-width: 11rem; line-height: 1.45; }

.case-section { margin-top: clamp(2rem, 5vw, 3rem); }
.case-section h2 { font-size: 1.25rem; margin-bottom: .9rem; }
.case-body { max-width: var(--measure); }

.subcards { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); margin-top: 1.5rem; max-width: var(--measure); }
.subcard h3 { font-family: var(--sans); font-size: .875rem; font-weight: 600; color: var(--ink); margin-bottom: .35rem; }
.subcard p { font-size: .8125rem; }

.limits { max-width: var(--measure); }
.limits li { position: relative; padding-left: 1.1rem; font-size: .875rem; }
.limits li + li { margin-top: .7rem; }
.limits li::before { content: "—"; position: absolute; left: 0; color: var(--ink-muted); }

.pager { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; margin-top: clamp(2.5rem, 6vw, 4rem); padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.pager__item {
  display: flex; flex-direction: column; gap: .35rem; flex: 1 1 12rem;
  text-decoration: none; border: 1px solid var(--rule); border-radius: 3px;
  padding: 1rem 1.25rem;
  /* The reveal moves the whole .pager, so an item only takes the hover lift. */
  transform: translateY(var(--rise, 0px));
  transition: transform .28s var(--ease), border-color .28s ease, box-shadow .3s ease,
              background-color .28s ease, opacity .5s ease;
}
.pager__item:hover, .pager__item:focus-visible {
  border-color: var(--accent); background: var(--paper-sunk); box-shadow: var(--shadow);
}
@media (hover: hover) { .pager__item:hover { --rise: -3px; } }
.pager__item--next { align-items: flex-end; text-align: right; }
.pager__label { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.pager__title { font-size: 1rem; font-weight: 500; color: var(--accent); }
.pager__item:hover .pager__title { text-decoration: underline; text-underline-offset: 2px; }

/* --- Interaction ----------------------------------------------------------
   Everything here is hover/scroll behaviour rather than layout. Four custom
   properties drive every transform on the page: --rise (hover lift), --shift
   (hover nudge), --pop (hover scale) and --enter (the on-scroll reveal). They
   are separate so a hover state and the reveal can move the same element
   without either overwriting the other's `transform`.

   The reveal is gated on a `js` class that the page adds to <html> ONLY when
   the visitor has not asked for reduced motion. No script, or reduced motion:
   nothing is ever hidden, and the page renders exactly as it did before.
   -------------------------------------------------------------------------- */

/* Body links: a soft rule at rest, with the accent wiping across it on hover. */
.hero__body a:not(.btn), .prose a:not(.btn), .case-body a:not(.btn), .limits a:not(.btn) {
  text-decoration: none;
  padding-bottom: 2px;
  background-image:
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--ink-muted), var(--ink-muted));
  background-repeat: no-repeat;
  background-position: 0 100%, 0 100%;
  background-size: 0 2px, 100% 1px;
  transition: background-size .36s var(--ease), color .2s ease;
}
.hero__body a:not(.btn):hover, .prose a:not(.btn):hover,
.case-body a:not(.btn):hover, .limits a:not(.btn):hover,
.hero__body a:not(.btn):focus-visible, .prose a:not(.btn):focus-visible,
.case-body a:not(.btn):focus-visible, .limits a:not(.btn):focus-visible {
  background-size: 100% 2px, 100% 1px;
}

/* Fallback for a case study with no live link: the plain image still lifts
   off the page under the cursor. .shot__link (above) handles the linked case. */
.shot > img { transition: box-shadow .35s ease; }
.shot > img:hover { box-shadow: var(--shadow); }

/* On-scroll reveal: each block fades up once, the first time it comes into
   view. The hidden state is written as :not(.is-in) rather than being undone by
   a separate .is-in rule, because a target selected through a type selector
   (.contact__list li) outweighs a plain .is-in and would never have come back.

   Cards, list rows and the pager already declare their own transform and
   transition for hover, so they take only the offset here. */
.js .section__head:not(.is-in),
.js .card:not(.is-in),
.js .list__row:not(.is-in),
.js .role:not(.is-in),
.js .meta:not(.is-in),
.js .shot:not(.is-in),
.js .figs:not(.is-in),
.js .case-section:not(.is-in),
.js .pager:not(.is-in),
.js .contact__list li:not(.is-in) {
  opacity: 0;
  --enter: 14px;
}
.js .section__head,
.js .role,
.js .meta,
.js .shot,
.js .figs,
.js .case-section,
.js .pager,
.js .contact__list li {
  transform: translateY(var(--enter, 0px));
  transition: opacity .6s ease, transform .6s var(--ease);
}

/* --- Motion / print ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  /* Hover transforms are dropped too, so nothing jumps under the cursor. */
  .card:hover, .card:focus-visible, .card:active,
  .list__row:hover, .pager__item:hover,
  .theme-toggle:hover, .theme-toggle:active, .btn:hover, .btn:active { transform: none; }
  .card:hover .card__media img { transform: none; }
  .shot__link:hover img, .shot__link:focus-visible img { transform: none; }
}
@media print {
  .site-header, .pager { display: none; }
  body { background: #fff; color: #000; }
  /* An unrevealed element would otherwise print blank. */
  body * { opacity: 1 !important; transform: none !important; box-shadow: none !important; }
}
