/* ==========================================================================
   components.css
   Shared components. Each block notes its Figma source component.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Colour themes   (Figma: Project card "Colour" / Gradient variables)
   Add one of these classes to set a card's or banner's gradient.
   -------------------------------------------------------------------------- */
.colour-orange {
  --colour-start: var(--gradient-orange-start);
  --colour-end:   var(--gradient-orange-end);
}
.colour-lavender {
  --colour-start: var(--gradient-lavender-start);
  --colour-end:   var(--gradient-lavender-end);
}
.colour-mint {
  --colour-start: var(--gradient-mint-start);
  --colour-end:   var(--gradient-mint-end);
}

.colour-gradient {
  background-image: linear-gradient(var(--gradient-direction), var(--colour-start), var(--colour-end));
}

/* --------------------------------------------------------------------------
   Site header / Nav   (Figma: "Nav" — links are Button Ghost L)
   -------------------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-white);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;          /* name left, links right — no extra gap, as in Figma */
  row-gap: var(--space-xs);                 /* only used if it ever has to wrap */
  padding-block: var(--space-lg);          /* 20 */
}

.site-nav__logo {
  font-family: var(--font-heading);
  font-size: var(--type-logo);
  font-weight: 700;
  line-height: var(--leading-heading);
  color: var(--color-text-primary);
  text-decoration: none;
}

.site-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-nav-gap);             /* 0 → 8 */
  /* the buttons' own 16px padding lines the last label up 16px inside the margin, as in Figma */
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Small phones: the name + three links need ~348px at 16px padding. Narrow the
   padding just enough to stay on one line (16px from 400px wide, 8px at 348px). */
@media (max-width: 24.99rem) { /* < 400px */
  .site-nav__links .btn {
    --btn-px: clamp(0.5rem, (100vw - 18.75rem) / 6, 1rem);
  }
}

/* Current page: underlined so it isn't shown by colour alone */
.site-nav__links .btn[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

/* --------------------------------------------------------------------------
   Icons
   Icons are SVG files exported from Figma (assets/icons/), applied as a CSS
   mask so their colour follows the text colour ("stroke follows the button
   text colour", as described on the Figma component).
   -------------------------------------------------------------------------- */
.icon {
  display: inline-block;
  flex: none;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}

.icon--arrow-right { --icon: url("/assets/icons/arrow-right.svg"); }
.icon--download    { --icon: url("/assets/icons/download.svg"); }

/* --------------------------------------------------------------------------
   Buttons   (Figma: Design System › "Button")
   Variant:  .btn--primary · .btn--secondary · .btn--ghost · .btn--link
   Size:     .btn--xl (56 · 48 on mobile) · .btn--l (40) · .btn--s (24)
   Icon:     add <span class="icon icon--…" aria-hidden="true"></span>
   State:    :hover, and disabled via [aria-disabled="true"] or :disabled
   -------------------------------------------------------------------------- */
.btn {
  --btn-h: 2.5rem;                       /* L by default */
  --btn-px: var(--space-md);             /* 16 */
  --btn-gap: var(--space-xs);            /* 8 */
  --btn-font: 1rem;                      /* 16 */
  --btn-lh: 1.2;
  --btn-icon: 1rem;                      /* 16 */

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--btn-gap);
  height: var(--btn-h);
  padding: 0 var(--btn-px);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-primary);
  font-family: var(--font-heading);
  font-size: var(--btn-font);
  font-weight: 500;
  line-height: var(--btn-lh);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration) var(--ease-out),
    border-color var(--duration) var(--ease-out),
    color var(--duration) var(--ease-out);
}

.btn .icon {
  width: var(--btn-icon);
  height: var(--btn-icon);
}

/* ---- Sizes ------------------------------------------------------------------ */
.btn--xl {
  --btn-h: var(--size-button-height);    /* 56 · 48 on mobile */
  --btn-px: var(--space-lg);             /* 20 */
  --btn-lh: 1.3;
}

.btn--l {
  --btn-h: 2.5rem;                       /* 40 */
  --btn-px: var(--space-md);             /* 16 */
}

.btn--s {
  --btn-h: 1.5rem;                       /* 24 */
  --btn-px: var(--space-md);             /* 16 */
  --btn-gap: var(--space-2xs);           /* 4 */
  --btn-font: 0.875rem;                  /* 14 */
  --btn-icon: 0.75rem;                   /* 12 */
}

/* ---- Variants ---------------------------------------------------------------- */
/* Primary — main call to action */
.btn--primary {
  background: var(--color-text-primary);
  color: var(--color-cream);
}
.btn--primary:hover {
  background: var(--color-accent);
}

/* Secondary — outlined */
.btn--secondary {
  border-color: var(--color-text-primary);
}
.btn--secondary:hover {
  background: var(--color-surface);
}

/* Ghost — no border or fill: nav and low-emphasis actions */
.btn--ghost:hover {
  color: var(--color-text-faint);
}

/* Link — underlined text, no box (XL 16 · L 14 · S 12) */
.btn--link {
  height: auto;
  padding: var(--space-2xs) 0;           /* 4 0 */
  border: 0;
  border-radius: 0;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.btn--link.btn--xl { --btn-font: 1rem;     --btn-lh: 1.2; }  /* 16 */
.btn--link.btn--l  { --btn-font: 0.875rem; }                 /* 14 */
.btn--link.btn--s  { --btn-font: 0.75rem;  }                 /* 12 */
.btn--link:hover {
  color: var(--color-accent);
}

/* ---- Disabled ------------------------------------------------------------------ */
.btn:disabled,
.btn[aria-disabled="true"] {
  pointer-events: none;
  color: var(--color-text-faint);
}
.btn--primary:disabled,
.btn--primary[aria-disabled="true"] {
  background: var(--color-border);
}
.btn--secondary:disabled,
.btn--secondary[aria-disabled="true"] {
  border-color: var(--color-border);
  background: transparent;
}
.btn--ghost:disabled,
.btn--ghost[aria-disabled="true"] {
  color: var(--color-dashed-border);
}

/* --------------------------------------------------------------------------
   Media / image placeholders
   Every image surface has 24px corners. Swap images by replacing the file
   at the same path (see README → "Image checklist").
   -------------------------------------------------------------------------- */
.media {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
}

.media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Images exported square and borderless from Figma: corners (above) and the
   1px border are drawn here so they stay crisp and match at any size. */
.media--bordered::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--color-border);
  border-radius: inherit;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Project card   (Figma: "Project card" — Brand × Size × State)
   Whole card is clickable via a stretched link on the title.
   Mockup position comes from Figma (px inside the 648×400 card image):
     --x, --y = top-left of the device mockup, --w = mockup width.
   -------------------------------------------------------------------------- */
.work-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem var(--grid-gutter); /* 40px between projects on mobile */
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 48rem) { /* bp: tablet (≥ 768px) — more space between cards */
  .work-grid {
    row-gap: var(--space-4xl);
  }
}

@media (min-width: 64rem) { /* bp: desktop (≥ 1024px) — 2 cards per row */
  .work-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.project-card {
  position: relative;
  container-type: inline-size; /* card width drives the scale factor below */
  display: flex;
  flex-direction: column;
  gap: var(--space-sm); /* 12px image → text (Breakpoint=Mobile) */

  /* --k = one Figma pixel. Cards never grow past their Figma size: wider cards
     show more gradient, narrower ones scale down.
     Breakpoint=Mobile: card image 342×280. */
  --k: min(1px, 100cqw / 342);
  --card-h: 280;
  --device-top: 70;
  --lift: 10.5;       /* hover rise (15 × 0.7) */
  --device-scale: 0.7;
}

@media (min-width: 48rem) { /* bp: tablet (≥ 768px) — Breakpoint=Desktop card: 648×400 */
  .project-card {
    gap: var(--space-2xl); /* 32px image → text */
    --k: min(1px, 100cqw / 648);
    --card-h: 400;
    --device-top: 100;
    --lift: 15;
    --device-scale: 1;
  }
}

.project-card__media {
  position: relative;
  height: calc(var(--card-h) * var(--k));
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* 1px border appears on hover (Figma "State=Hover") — drawn on top of the
   mockup so it doesn't shift the layout. */
.project-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  border-radius: inherit;
  pointer-events: none;
  transition: border-color var(--duration) var(--ease-out);
}

/* Device mockup (Figma: Device component), centred like Figma's auto-layout.
   Shadow and top corners are drawn here, not baked into the image. */
.project-card__mockup {
  --px: calc(var(--device-scale) * var(--k));
  position: absolute;
  left: 50%;
  top: calc(var(--device-top) * var(--k));
  width: calc(var(--device-w) * var(--px));
  max-width: none;
  height: auto;
  transform: translateX(-50%);
  border-radius: calc(var(--radius) * var(--px)) calc(var(--radius) * var(--px)) 0 0;
  box-shadow: 0 calc(var(--shadow-y) * var(--px)) calc(var(--shadow-blur) * var(--px)) var(--shadow-mockup-color);
  transition: transform 400ms var(--ease-out);
}

/* Device Type — values from Figma's Device component at 1× */
.project-card__mockup--mobile-screen {
  --device-w: 204;
  --radius: 38;
  --shadow-y: 13.5;
  --shadow-blur: 40.5;
}

.project-card__mockup--desktop-screen {
  --device-w: 560;
  --radius: 14;
  --shadow-y: 16;
  --shadow-blur: 48;
}

.project-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

@media (min-width: 48rem) { /* bp: tablet (≥ 768px) */
  .project-card__body { gap: var(--space-sm); }
}

.project-card__company {
  order: -1; /* visually above the title; title stays first for screen readers */
  font-size: var(--type-body-sm);
  line-height: var(--leading-small);
  color: var(--color-text-muted);
}

.project-card__title {
  max-width: 37.5rem; /* 600 */
  font-size: var(--type-h3);
  font-weight: 600;
  transition: color var(--duration) var(--ease-out);
}

.project-card__title a {
  color: inherit;
  text-decoration: none;
}

/* Stretched link: the whole card is the click target */
.project-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.project-card__title a:focus-visible {
  outline: none;
}

.project-card__desc {
  max-width: 35rem; /* 560 */
  color: var(--color-text-muted);
}

/* Hover & keyboard focus: border, accent title, device rises */
.project-card:hover .project-card__media::after,
.project-card:focus-within .project-card__media::after {
  border-color: var(--color-border);
}

.project-card:hover .project-card__title,
.project-card:focus-within .project-card__title {
  color: var(--color-accent);
}

.project-card:hover .project-card__mockup,
.project-card:focus-within .project-card__mockup {
  transform: translate(-50%, calc(var(--lift) * -1 * var(--k)));
}

/* Visible focus ring around the whole card */
.project-card:has(.project-card__title a:focus-visible) .project-card__media {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* --------------------------------------------------------------------------
   Project header   (Figma: "Project header", Layout=banner)
   The top visual is a pure CSS gradient (no image), left → right.
   -------------------------------------------------------------------------- */
.project-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2xl) 2.5rem; /* 32 / 40 */
  padding-top: clamp(4rem, 3.2571rem + 3.0476vw, 6rem);     /* 64 → 96 */
  padding-bottom: clamp(2.5rem, 2.2rem + 1.2190vw, 3.5rem); /* 40 → 56 */
}

.project-header__title-group {
  flex: 1 1 0;
  min-width: min(20rem, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.project-header__title {
  font-size: var(--type-display);
  line-height: var(--leading-heading);
}

.project-header__meta {
  flex: 1 1 0;
  min-width: min(20rem, 100%);
  max-width: 30rem; /* 480 */
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.75rem 3.5rem; /* 28 / 56 */
}

.project-header__meta div {
  display: flex;
  flex-direction: column;
  gap: 0.375rem; /* 6 */
}

.project-header__meta div:first-child { min-width: 9.375rem; } /* 150 */
.project-header__meta div:last-child  { flex: 1 1 0; min-width: 12.5rem; } /* 200 */

.project-header__meta dt {
  font-size: var(--type-caption);
  color: var(--color-text-muted);
}

.project-header__meta dd {
  font-size: 0.9375rem; /* 15 */
  color: var(--color-text-body);
}

/* Banner under the project header: a pure CSS gradient (no image), left → right.
   Figma: Project header, Layout=banner.
   Proportional: always the Desktop shape (1312×200). Everything inside scales
   with the banner's width and stops at the Desktop size (1312px, the
   .container maximum).  390px screen → 342×52 · 1440px+ → 1312×200.        */
.project-banner {
  container-type: inline-size;        /* wordmark sizes are % of banner width */
  position: relative;
  aspect-ratio: 1312 / 200;
  overflow: hidden;
  /* 24px at 1312 wide, scaling with it: % of width / % of height */
  border-radius: 1.8293% / 12%;
  background-image: linear-gradient(var(--gradient-direction), var(--colour-start), var(--colour-end));
}

/* Large project word, white at 40%, cropped by the banner's bottom edge.
   Figma Desktop: 260px, right 17, top −6 — all ÷1312 of the banner width. */
.project-banner__wordmark {
  position: absolute;
  right: calc(17 / 1312 * 100cqw);
  top: calc(-6 / 1312 * 100cqw);
  font-family: var(--font-heading);
  font-size: calc(260 / 1312 * 100cqw);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.04em;
  white-space: nowrap;
  color: #fff;
  opacity: 0.4;
  user-select: none;
}

/* --------------------------------------------------------------------------
   Contact / Let's talk   (Figma: "Contact / Let's talk")
   -------------------------------------------------------------------------- */
.contact {
  padding-top: var(--space-contact-top);
}

.contact__inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xl);
  border-top: 1px solid var(--color-border);
  padding-top: 4rem; /* 40 spacer + 24 gap */
}

.contact__title {
  font-size: var(--type-title);
}

.contact__subtitle {
  max-width: 40rem; /* 640 */
  font-size: var(--type-subtitle);
  color: var(--color-text-muted);
}

.contact__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md) var(--space-2xl);
  margin: 0;
  padding: var(--space-md) 0 0;
  list-style: none;
}

@media (max-width: 47.99rem) { /* bp: mobile (< 768px) */
  .contact__actions {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   Footer   (Figma: "Footer")
   -------------------------------------------------------------------------- */
.site-footer {
  padding-top: var(--space-footer-top);
  padding-bottom: var(--space-3xl);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-2xl);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__links a {
  font-size: var(--type-body-sm);
  line-height: var(--leading-small);
  color: var(--color-text-primary);
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* --------------------------------------------------------------------------
   Split section: label on the left, content on the right
   (Figma: CV sections; also used by project page sections)
   bp desktop (≥ 1024px): label column + 656px content column. Below: stacked.
   -------------------------------------------------------------------------- */
/* Space above the divider + below it = gap between sections.
   390px: 40 + 40 = 80   ·   1440px: 144 + 120 = 264 (Figma) */
.split {
  padding-top: clamp(2.5rem, 0.6429rem + 7.6190vw, 7.5rem);    /* 40 → 120 */
}

.split__inner {
  display: grid;
  gap: var(--space-md);
  padding-bottom: clamp(2.5rem, 0.0857rem + 9.9048vw, 9rem);   /* 40 → 144 */
  border-bottom: 1px solid var(--color-border);
}

.split__label {
  font-size: var(--type-h3);
  font-weight: 600;
  line-height: normal;
}

@media (min-width: 64rem) { /* bp: desktop (≥ 1024px) */
  .split__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 41rem); /* content 656 */
    gap: var(--space-xl);
  }
}

/* --------------------------------------------------------------------------
   Other projects   (Figma: "Other projects" + "project-link", end of each project page)
   Three links to other projects, then "See all work" (Button Primary XL, arrow).
   -------------------------------------------------------------------------- */
.other-projects {
  padding-top: clamp(4.5rem, 3.3857rem + 4.5714vw, 7.5rem);   /* 72 → 120 */
}

.other-projects__title {
  font-size: var(--type-h2);                                  /* 28 → 40 */
}

.other-projects__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-link {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);                                       /* 16 */
  padding-block: var(--space-xl);                             /* 24 */
  border-bottom: 1px solid var(--color-border);
}

.project-link__company {
  order: -1;                       /* shown above the title; title first for screen readers */
  line-height: var(--leading-small);
  color: var(--color-text-muted);
}

.project-link__title {
  max-width: 32.5rem;                                         /* 520 */
  font-size: var(--type-link);                                /* 18 */
  font-weight: 600;
}

.project-link__title a {
  color: var(--color-text-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--duration) var(--ease-out);
}

.project-link__title a::after {    /* whole row is clickable */
  content: "";
  position: absolute;
  inset: 0;
}

.project-link:hover .project-link__title a,
.project-link__title a:focus-visible {
  color: var(--color-accent);
}

.project-link:has(a:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.project-link__title a:focus-visible {
  outline: none;
}

.other-projects__more {
  padding-top: clamp(2.5rem, 1.9429rem + 2.2857vw, 4rem);    /* 40 → 64 */
}
