/* ==========================================================================
   work.css - individual project case-study pages (/work/<slug>)
   Builds on the tokens and components defined in index.css.

   Two page flavours share this sheet:
     .cs-tech   - product / engineering write-ups (EduPay, microTCP, ...)
     .cs-client - client website write-ups, where the outcome is the client's
                  own words rather than a metric.
   The only difference is which blocks the page includes; the layout,
   typography and spacing are deliberately identical so the set reads as one
   body of work.
   ========================================================================== */

/* ---------- Page head ---------- */
.cs-hero {
  padding-top: calc(var(--nav-h) + clamp(2.2rem, 6vh, 4rem));
  padding-bottom: clamp(1.4rem, 3vw, 2.2rem);
  position: relative;
}
.cs-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(700px 420px at 78% -10%, rgba(91, 78, 240, 0.1), transparent 62%),
    radial-gradient(460px 340px at 4% 80%, rgba(255, 188, 143, 0.08), transparent 60%);
}

/* Breadcrumb doubles as the back link: on a deep page reached from search,
   it is the only affordance pointing back into the site. */
.cs-crumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--ink-3);
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.cs-crumbs a { color: var(--ink-2); font-weight: 500; }
.cs-crumbs a:hover { color: var(--accent-deep); }
.cs-crumbs span[aria-current] { color: var(--ink); font-weight: 600; }
.cs-crumbs .sep { color: var(--ink-3); }

.cs-hero h1 {
  font-size: clamp(2.4rem, 5.4vw, 4rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.04;
  margin-bottom: 0.7rem;
}
.cs-lead {
  color: var(--ink-2);
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  line-height: 1.6;
  max-width: 58ch;
  margin: 0 0 1.6rem;
}
.cs-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
}

/* ---------- Hero screenshot ---------- */
.cs-shot {
  margin: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-deep);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
/* height:auto is load-bearing. The width/height attributes on these images are
   there to reserve space and avoid layout shift, but the HTML height attribute
   maps to a presentational hint on the CSS height property, which outranks
   aspect-ratio. Without this the box is <natural height>px tall and object-fit
   crops a tall slice out of a wide screenshot. */
.cs-shot img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top center;
}
.cs-shot-cap {
  padding: 0.8rem 1.2rem;
  font-size: 0.83rem;
  color: var(--ink-3);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

/* ---------- Headline metrics ---------- */
.cs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: clamp(1.6rem, 3vw, 2.4rem);
  padding: clamp(1.3rem, 3vw, 1.8rem) clamp(1rem, 3vw, 2rem);
  border-radius: var(--r-lg);
  background: var(--surface-glass);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
}

/* ---------- Body layout ---------- */
.cs-body { padding-block: clamp(2.4rem, 5vw, 4rem); }
.cs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

/* The fact panel comes first in the DOM so that on a phone it lands directly
   under the hero, where it works as a summary. On desktop it belongs on the
   right, so both children are placed explicitly rather than by source order,
   which would otherwise hand the 1fr column to the sidebar. */
.cs-main {
  grid-column: 1;
  grid-row: 1;
  max-width: 68ch;
}

/* ---------- Sticky fact panel ---------- */
.cs-aside {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}
.cs-facts {
  padding: 1.4rem 1.5rem;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-glass);
  margin: 0;
}
.cs-facts dl { margin: 0; }
.cs-facts h2 {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 1.1rem;
}
.cs-facts dt {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.2rem;
}
.cs-facts dd {
  margin: 0 0 1rem;
  font-size: 0.93rem;
  color: var(--ink);
  line-height: 1.5;
}
.cs-facts dd:last-child { margin-bottom: 0; }
.cs-facts .chips { margin-top: 0.15rem; }
.cs-facts .chip { font-size: 0.76rem; }

/* ---------- Prose blocks ---------- */
.cs-block { margin-bottom: clamp(2.2rem, 4vw, 3.2rem); }
.cs-block:last-child { margin-bottom: 0; }
.cs-block > h2 {
  font-size: clamp(1.45rem, 2.6vw, 1.9rem);
  font-weight: 700;
  margin: 0 0 0.9rem;
}
.cs-block > h3 {
  font-size: 1.08rem;
  margin: 1.8rem 0 0.5rem;
}
.cs-block p {
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.72;
}
.cs-block p strong { color: var(--ink); font-weight: 600; }
.cs-block > p:last-child { margin-bottom: 0; }

/* Opening paragraph of a block, set slightly larger to give each section a
   visible entry point on a long page. */
.cs-block .cs-block-lead {
  font-size: 1.1rem;
  color: var(--ink);
}

/* ---------- Feature / scope list ---------- */
.cs-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
  display: grid;
  gap: 0.7rem;
}
.cs-list li {
  position: relative;
  padding-left: 1.75rem;
  color: var(--ink-2);
  line-height: 1.6;
}
.cs-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--violet));
}
.cs-list li strong { color: var(--ink); font-weight: 600; }

/* ---------- Decision cards ----------
   The part of a case study that actually signals engineering judgement:
   what was chosen, why, and what it cost. */
.cs-decisions {
  display: grid;
  gap: 1rem;
  margin: 1.4rem 0 0;
}
.cs-decision {
  padding: 1.2rem 1.35rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  box-shadow: 0 10px 30px -24px rgba(64, 56, 160, 0.25);
}
.cs-decision h3 {
  font-size: 1.02rem;
  font-weight: 650;
  margin: 0 0 0.5rem;
}
.cs-decision p {
  font-size: 0.95rem;
  margin: 0 0 0.6rem;
  color: var(--ink-2);
  line-height: 1.65;
}
.cs-decision p:last-child { margin-bottom: 0; }
.cs-decision .cs-tradeoff {
  font-size: 0.88rem;
  color: var(--ink-3);
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line-strong);
}
.cs-decision .cs-tradeoff strong {
  color: var(--ink-2);
  font-weight: 600;
}

/* ---------- Client quote ---------- */
.cs-quote {
  margin: 1.6rem 0 0;
  padding: clamp(1.5rem, 3vw, 2.1rem) clamp(1.4rem, 3vw, 2.2rem);
  border-radius: var(--r-lg);
  background:
    radial-gradient(420px 220px at 12% 0%, rgba(91, 78, 240, 0.07), transparent 70%),
    var(--surface);
  border: 1px solid var(--accent-soft-2);
  box-shadow: var(--shadow-glass);
  position: relative;
}
.cs-quote::before {
  content: "\201C";
  position: absolute;
  top: 0.1em;
  left: 0.35rem;
  font-family: var(--font-display);
  font-size: 4.5rem;
  line-height: 1;
  color: var(--accent-soft-2);
  pointer-events: none;
}
.cs-quote p {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.9vw, 1.24rem);
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1rem;
}
.cs-quote footer {
  font-size: 0.88rem;
  color: var(--ink-2);
}
.cs-quote footer strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Gallery ---------- */
.cs-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}
.cs-gallery figure {
  margin: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-deep);
  border: 1px solid var(--line);
}
.cs-gallery img {
  width: 100%;
  height: auto;              /* see the note on .cs-shot img */
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top center;
}
.cs-gallery figcaption {
  padding: 0.7rem 0.9rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  background: var(--surface);
}

/* ---------- Prev / next ---------- */
.cs-nav { padding-block: 0 clamp(2.4rem, 5vw, 3.6rem); }
.cs-nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.cs-nav-card {
  display: block;
  padding: 1.2rem 1.4rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: border-color 0.25s, box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.cs-nav-card:hover {
  color: var(--ink);
  border-color: var(--accent-soft-2);
  box-shadow: var(--shadow-lift);
  transform: translateY(-2px);
}
.cs-nav-card span {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.35rem;
}
.cs-nav-card strong {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.cs-nav-card.is-next { text-align: right; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .cs-layout { grid-template-columns: 1fr; }
  .cs-main {
    grid-column: 1;
    grid-row: auto;
    max-width: none;
    order: 2;
  }
  .cs-aside {
    grid-column: 1;
    grid-row: auto;
    position: static;
    order: 1;
  }
}

@media (max-width: 560px) {
  .cs-nav-grid { grid-template-columns: 1fr; }
  .cs-nav-card.is-next { text-align: left; }
  .cs-shot img { aspect-ratio: 4 / 3; }
}
