/* ============================================================
   Ruth Kerbawy — Portfolio
   Plain CSS, mobile-first. See /CLAUDE.md for the token & type
   system this file implements.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Color */
  --bg: #fffefc;
  --fg: #191512;
  --fg-secondary: #423d38;
  --fg-inverted: #fffefc;
  --interactive-accent: #bd441e;
  --accent: #b3401d;
  --color-rust-400: #de6641;
  --bg-border: #f2eee7;
  --card: #ffffff;
  --white: #ffffff;

  /* Dark "About" panel + footer */
  --dark-bg: #191512;
  --dark-border: #2c136b;

  /* Type */
  --font-heading: "Space Grotesk", sans-serif;
  --font-body: "Work Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* Spacing scale (from Figma --scale/* tokens) */
  --space-50: 4px;
  --space-100: 8px;
  --space-200: 16px;
  --space-300: 24px;
  --space-400: 32px;
  --space-500: 40px;
  --space-600: 48px;
  --space-700: 56px;

  /* Layout */
  --page-gutter: 20px;
  --content-max: 1280px;
  --header-height: 72px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-family: var(--font-heading); font-weight: 500; }

/* Visible keyboard-focus indicator. --interactive-accent clears the 3:1
   non-text contrast minimum against every background used on the site
   (white, --bg-border, and --dark-bg), so one rule covers all contexts. */
a:focus-visible {
  outline: 2px solid var(--interactive-accent);
  outline-offset: 2px;
}

/* ---------- Shared layout ---------- */
.site-header,
.hero,
.case-studies,
.experience,
.about,
.contact,
.site-footer {
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
}

@media (min-width: 768px) {
  .site-header,
  .hero,
  .case-studies,
  .experience,
  .about,
  .contact,
  .site-footer {
    padding-left: var(--space-700);
    padding-right: var(--space-700);
  }
}

/* Caps content at very wide viewports; background/padding on the section
   itself is unaffected, so sections keep their own edge-to-edge behavior. */
.content-cap {
  max-width: 1728px;
  width: 100%;
  margin-inline: auto;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 16px;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0;
}
.eyebrow-inverted { color: var(--fg-inverted); }

.section-title {
  font-weight: 400;
  font-size: 28px;
  line-height: 1.15;
  color: var(--accent);
}
@media (min-width: 768px) {
  .section-title { font-size: 32px; line-height: 32px; }
}
.section-title-rust { color: var(--color-rust-400); }

.section-heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
  margin-bottom: var(--space-300);
}

/* Buttons */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-200);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-100) var(--space-200);
  border-radius: var(--space-400);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 24px;
  white-space: nowrap;
}
.btn-filled {
  background: var(--interactive-accent);
  color: var(--white);
  border: 1px solid var(--interactive-accent);
}
.btn-outline {
  background: transparent;
  color: var(--interactive-accent);
  border: 1px solid var(--interactive-accent);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding-top: var(--space-300);
  padding-bottom: var(--space-300);
}

/* Anchor targets: offset by the sticky header's height so a nav-link jump
   doesn't land with the target heading tucked underneath it. */
#case-studies,
#about,
#contact {
  scroll-margin-top: var(--header-height);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-200);
}
.wordmark { font-family: var(--font-body); font-weight: 500; font-size: 14px; }
.nav { display: flex; gap: var(--space-300); }
@media (min-width: 480px) {
  .nav { gap: 30px; }
}
.nav a {
  /* Reserve the underline's space at all times (transparent when inactive)
     so the color transition below doesn't come with a 1px layout jump —
     border-style/width can't animate smoothly, only its color can. */
  border-bottom: 1px solid transparent;
  transition: color 150ms ease, border-bottom-color 150ms ease;
}
.nav a.active,
.nav a:hover {
  color: var(--interactive-accent);
  border-bottom-color: var(--interactive-accent);
}
@media (prefers-reduced-motion: reduce) {
  .nav a { transition: none; }
}

/* ---------- Hero ---------- */
.hero {
  padding-top: var(--space-300);
  padding-bottom: var(--space-400);
}
.hero-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.hero h1 {
  font-size: 32px;
  line-height: 1.2;
  color: var(--fg);
}
.hero-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.hero .lede {
  color: var(--fg-secondary);
  max-width: 530px;
}
@media (min-width: 768px) {
  /* Figma's Hero frame treats nav+headline as one 64px-gapped group; our
     header and hero are separate elements, so the extra padding here
     (on top of .site-header's own 24px bottom padding) reproduces that
     64px total at desktop. Mobile keeps the tighter, unchanged gap. */
  .hero { padding-top: var(--space-500); }
  .hero h1 { font-size: 48px; line-height: 56px; max-width: 520px; }
}

/* ---------- Case Studies ---------- */
.case-studies {
  padding-top: var(--space-600);
  padding-bottom: var(--space-600);
}
.case-study-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.case-study-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--bg-border);
  border-radius: var(--space-200);
  overflow: clip;
  box-shadow: 0px 2px 4px 0px rgba(25, 21, 18, 0.03), 0px 4px 24px 0px rgba(25, 21, 18, 0.07);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow 150ms ease;
}
.case-study-card:hover {
  /* Same two-layer shadow, deepened slightly — a subtle cue that the
     whole card (not just the "View Case Study" text) is clickable. */
  box-shadow: 0px 2px 4px 0px rgba(25, 21, 18, 0.06), 0px 8px 32px 0px rgba(25, 21, 18, 0.12);
}
@media (prefers-reduced-motion: reduce) {
  .case-study-card { transition: none; }
}
.case-study-cover { width: 100%; height: 240px; }
.case-study-cover img { width: 100%; height: 100%; object-fit: cover; }

/* These four rows carry the padding/spacing that used to live on the
   .case-study-body/.case-study-heading wrapper divs — flattened so each
   row can be a direct subgrid item at 900px+ (see below). Values are
   unchanged from before, just relocated: 24px card inset, 8px title-to-
   description gap, 16px gap above tags/button. */
.case-study-title-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-50);
  padding: var(--space-300) var(--space-300) 0;
}
.case-study-title-group h3 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 20px;
  line-height: 24px;
  color: var(--fg);
}
.case-study-desc {
  color: var(--fg-secondary);
  padding: var(--space-100) var(--space-300) 0;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-100);
  padding: var(--space-200) var(--space-300) 0;
}
.tag {
  background: var(--bg-border);
  color: var(--fg-secondary);
  font-size: 12px;
  line-height: 16px;
  padding: var(--space-50) var(--space-100);
  border-radius: 100px;
}
.view-case-study {
  display: inline-flex;
  align-items: center;
  gap: var(--space-100);
  color: var(--interactive-accent);
  font-weight: 500;
  font-size: 14px;
  /* top: 16px gap-above + this element's own 4px micro-padding.
     bottom: 24px card inset + the same 4px micro-padding. */
  padding: calc(var(--space-200) + var(--space-50)) var(--space-300) calc(var(--space-300) + var(--space-50));
}

@media (min-width: 900px) {
  /* Subgrid: the parent defines 5 row tracks per row-group (cover,
     title, description, tags, button), repeated (via repeat(2, …)) so
     a wrapped row (e.g. a 3rd card alone in column 1) gets its own
     full row-group of tracks instead of falling back to nameless
     implicit ones. Each card subgrids its rows and its 5 children
     reference LOCAL numeric line positions (1/2 … 5/6) rather than
     named lines — subgrid correctly rescopes plain numeric indices to
     an item's own spanned tracks regardless of which row-group it
     sits in, whereas a bare named line repeated by repeat() is NOT
     reliably rescoped the same way (confirmed: it resolved to the
     wrong row-group's line in testing, floating the button into the
     empty cell instead of its own card). Each card's own row-group +
     column is set explicitly per nth-child rather than via `span`, so
     placement is deterministic at both breakpoints. */
  .case-study-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(2, auto auto auto auto auto);
    column-gap: var(--space-300);
    row-gap: 0;
  }
  .case-study-card {
    display: grid;
    grid-template-rows: subgrid;
    row-gap: 0;
  }
  .case-study-cover { grid-row: 1 / 2; height: 280px; }
  .case-study-title-group { grid-row: 2 / 3; }
  .case-study-desc { grid-row: 3 / 4; }
  .tag-list { grid-row: 4 / 5; }
  .view-case-study { grid-row: 5 / 6; }

  /* Cards 1-2: row-group 1 (tracks 1-5), columns 1 and 2. */
  .case-study-card:nth-child(-n+2) { grid-row: 1 / 6; }
  .case-study-card:nth-child(1) { grid-column: 1; }
  .case-study-card:nth-child(2) { grid-column: 2; }
  /* Card 3 wraps into row-group 2 (tracks 6-10), column 1 only —
     not stretched across both columns, second column left empty.
     row-gap stays 0 above (a uniform row-gap would also land between
     each card's own internal cover/title/desc/tags/button tracks), so
     the gap between the two card rows is a top margin on the wrapped
     card instead — reset back to 0 at 1440px, where it sits inline in
     the single row with no row gap needed. */
  .case-study-card:nth-child(3) { grid-row: 6 / 11; grid-column: 1; margin-top: var(--space-300); }
}

@media (min-width: 1440px) {
  /* 3 cards fit a single row at this width. Only the column count and
     card 3's placement change — the subgrid setup and the 5 children's
     local row assignments above still apply unchanged. */
  .case-study-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .case-study-card:nth-child(3) { grid-row: 1 / 6; grid-column: 3; margin-top: 0; }
  .case-study-cover { height: 240px; }
}

/* ---------- Experience ---------- */
.experience {
  padding-top: var(--space-400);
  padding-bottom: var(--space-400);
}
.experience-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-400);
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.timeline-entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
}
.timeline-date {
  color: var(--fg-secondary);
  flex-shrink: 0;
}
.timeline-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
}
.timeline-meta { color: var(--fg-secondary); }
.company {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--interactive-accent);
}
.timeline-role {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 20px;
  line-height: 24px;
  color: var(--fg);
}
.timeline-desc { color: var(--fg-secondary); max-width: 520px; }
.divider { width: 100%; height: 1px; border: 0; }
.education { display: flex; flex-direction: column; gap: var(--space-200); }

@media (min-width: 768px) {
  .timeline-entry { flex-direction: row; gap: var(--space-400); align-items: flex-start; }
  .timeline-date { width: 140px; }
  .timeline-content { flex: 1 1 0; min-width: 0; }
  .education .timeline-entry { flex-direction: row; }
}

/* ---------- About ---------- */
.about { padding-top: var(--space-700); padding-bottom: var(--space-700); }
.about-card {
  background: var(--dark-bg);
  border: 1px solid var(--dark-border);
  border-radius: var(--space-300);
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);
  padding: var(--space-400);
}
.about-card-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-400);
}
.about-photo { width: 100%; }
.about-photo img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: var(--space-200);
}
.about-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-600);
}
.about-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
}
.about-intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
}
.about-bring {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
}
.about-bio { display: flex; flex-direction: column; color: var(--fg-inverted); gap: var(--space-300); }
.bring-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
}
.bring-list li {
  display: flex;
  align-items: center;
  gap: var(--space-100);
  color: var(--fg-inverted);
}

@media (min-width: 900px) {
  .about-card { padding: var(--space-600) var(--space-700); }
  .about-card-inner { flex-direction: row; align-items: center; }
  .about-photo { flex: 1 1 0; align-self: stretch; }
  .about-photo img { height: 100%; min-height: 420px; }
  .about-content { flex: 1 1 0; padding: 0 var(--space-200); }
}

/* ---------- Contact ---------- */
.contact {
  padding-top: var(--space-200);
  padding-bottom: calc(var(--space-700) + var(--space-200));
}
.contact-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-300);
}
.contact-heading { align-items: center; margin-bottom: 0; }
.contact-blurb { color: var(--fg-secondary); max-width: 400px; }

/* ---------- Case Study Detail ---------- */
.study-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-400);
  padding: var(--space-300) var(--page-gutter);
}
@media (min-width: 768px) {
  .study-page { padding: var(--space-300) var(--space-700); gap: var(--space-600); }
}

.study-eyebrow {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 24px;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0;
}

.study-cover {
  width: 100%;
  aspect-ratio: 1920 / 800;
  overflow: clip;
  border-radius: var(--space-200);
}
.study-cover img { width: 100%; height: 100%; object-fit: cover; }

.study-title {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
  width: 100%;
}
.study-title h1 {
  font-size: 32px;
  line-height: 1.2;
  color: var(--fg);
}
@media (min-width: 768px) {
  .study-title h1 { font-size: 48px; line-height: 56px; }
}

.study-meta-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
  width: 100%;
}
@media (min-width: 768px) {
  .study-meta-row { flex-direction: row; gap: var(--space-400); align-items: flex-start; }
}
.study-meta-row .lede { flex: 1 1 0; min-width: 0; color: var(--fg-secondary); max-width: none; }
.study-meta {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  color: var(--fg-secondary);
}
@media (min-width: 768px) {
  .study-meta { width: 300px; }
}
.study-meta strong { font-weight: 600; }

.study-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.study-body h2 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 20px;
  line-height: 24px;
  color: var(--fg);
}
.study-body h3 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  line-height: 24px;
  color: var(--fg);
}
.study-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
  width: 100%;
}
.study-body p, .study-body li { color: var(--fg-secondary); }
.study-body ul {
  list-style: disc;
  padding-left: 21px;
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
}

.study-image {
  width: 100%;
  height: auto;
  border-radius: var(--space-100);
}

.study-figure {
  display: flex;
  flex-direction: column;
  gap: var(--space-100);
  width: 100%;
  margin: 0;
}
.study-image-caption {
  font-size: 12px;
  line-height: 16px;
  color: var(--fg-secondary);
  text-align: center;
  padding-bottom: var(--space-100);
}

.study-key-decisions {
  background: var(--bg-border);
  border-radius: var(--space-200);
  padding: var(--space-400) var(--space-300);
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
}

.study-quote {
  display: flex;
  align-items: stretch;
  gap: var(--space-200);
}
.study-quote-bar {
  width: 8px;
  border-radius: var(--space-50);
  background: #e4ded3;
  flex-shrink: 0;
}
.study-quote p {
  font-size: 20px;
  line-height: 28px;
  color: var(--fg);
}
.study-quote em { font-style: italic; }

.study-statement {
  padding: var(--space-100) 0;
}
.study-statement p {
  font-size: 20px;
  line-height: 28px;
  color: var(--fg);
}

.study-nav {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: var(--space-100) 0;
}
.study-nav-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-200);
  width: 100%;
  max-width: 720px;
}
@media (min-width: 480px) {
  .study-nav-row { flex-direction: row; justify-content: space-between; }
}
.study-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-100);
  padding: var(--space-100) var(--space-200);
  border-radius: var(--space-400);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 24px;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Contact card (case study variant) ---------- */
.contact-section {
  padding: var(--space-300) var(--page-gutter);
}
@media (min-width: 768px) {
  .contact-section { padding: var(--space-700); }
}
.contact-card {
  width: 100%;
  background: var(--bg-border);
  border-radius: var(--space-200);
  padding: var(--space-600) var(--space-300);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-300);
}
.contact-card .contact-blurb { color: var(--fg); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--dark-bg);
  padding-top: var(--space-300);
  padding-bottom: var(--space-600);
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
}
@media (min-width: 480px) {
  .footer-inner { flex-direction: row; align-items: center; justify-content: space-between; }
}
.footer-name { display: flex; flex-direction: column; gap: var(--space-50); }
.footer-fullname { font-weight: 500; color: var(--fg-inverted); }
.footer-role { font-family: var(--font-mono); text-transform: uppercase; color: var(--color-rust-400); }
.footer-meta { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-100); }
@media (min-width: 480px) {
  .footer-meta { align-items: flex-end; }
}
.footer-copyright { color: var(--bg-border); font-size: 12px; }
.footer-badges { display: flex; gap: var(--space-50); }
