/* =============================================================================
   CRIS DEL NINNO — Project case-study pages
   Loaded after style-custom.css. Reuses every token defined there.
   Per-page accent: set --accent / --accent-soft inline on <body>.
   ============================================================================= */

:root { --accent-soft: rgba(0, 212, 255, 0.28); }

/* ---- Scaffold ---- */
.doc {
  max-width: 1040px;
  margin-inline: auto;
  padding: calc(var(--nav-h) + clamp(2.5rem, 7vw, 5rem)) clamp(1.25rem, 5vw, 3rem) 4rem;
}

.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
  transition: color var(--dur-hover) ease;
}
.doc-back svg {
  width: 14px; height: 14px;
  transition: transform var(--dur-ui) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .doc-back:hover { color: var(--accent); }
  .doc-back:hover svg { transform: translateX(-3px); }
}

/* ---- Hero ----------------------------------------------------------------
   The whole header used to appear with no entrance at all: the case studies
   opened flat while the home page opened in motion. It animates on load with a
   plain CSS sequence — no observer, so there is no window in which the type is
   invisible waiting for JavaScript.
   ------------------------------------------------------------------------- */
.proj-hero {
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
  perspective: 900px;          /* gives the title a shallow hinge, not a flat slide */
}

@media (prefers-reduced-motion: no-preference) {
  .doc-back, .proj-eyebrow, .proj-tagline, .proj-meta, .stack-pills {
    animation: rise 640ms var(--ease-out) both;
  }
  .proj-eyebrow  { animation-delay:  70ms; }
  .proj-tagline  { animation-delay: 240ms; }
  .proj-meta     { animation-delay: 310ms; }
  .stack-pills   { animation-delay: 380ms; }

  .proj-title {
    transform-origin: 50% 100%;
    animation: proj-title-in 820ms var(--ease-out) both;
    animation-delay: 130ms;
  }
}
@keyframes proj-title-in {
  from { opacity: 0; transform: translate3d(0, 30px, 0) rotateX(-24deg); }
}
.proj-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.proj-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 10vw, 7rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.045em;
  color: #fff;
  margin-bottom: 1.25rem;
}
.proj-tagline {
  font-size: clamp(1rem, 2.2vw, 1.28rem);
  line-height: 1.62;
  color: var(--text-2);
  max-width: 56ch;
  margin-bottom: 2rem;
}
.proj-tagline em { color: var(--accent); font-style: normal; }

.proj-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem 2.5rem;
  padding: 1.5rem 0;
  border-block: 1px solid var(--border);
  margin-bottom: 2rem;
}
.meta-item { display: flex; flex-direction: column; gap: 0.35rem; }
.meta-k {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta-v { font-size: 0.9rem; color: var(--text); }
.meta-v a { color: var(--accent); }
/* Unfilled metadata reads as "in progress", not as a broken em-dash. */
.meta-v[data-todo] { color: var(--muted); font-style: italic; }

.stack-pills { display: flex; flex-wrap: wrap; gap: 0.55rem; list-style: none; }
.stack-pill {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border-soft);
  border-radius: 100px;
  color: var(--muted);
  transition: color var(--dur-hover) ease, border-color var(--dur-hover) ease;
}
@media (hover: hover) and (pointer: fine) {
  .stack-pill:hover { border-color: var(--accent); color: var(--accent); }
}

/* ---- Primary shot ---- */
.proj-shot {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  margin-bottom: clamp(3rem, 7vw, 5rem);
}
.proj-shot img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Sections ---- */
.proj-section { margin-bottom: clamp(3rem, 7vw, 5rem); }
.doc-label {
  font-family: var(--font-mono);
  font-size: clamp(0.72rem, 1.6vw, 0.84rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.doc-h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 1.4rem;
}
.doc-p {
  font-size: 1.02rem;
  line-height: 1.8;
  color: var(--text-2);
  max-width: 68ch;
  margin-bottom: 1.15rem;
}
.doc-p strong { color: #fff; font-weight: 600; }
.doc-p em { color: var(--accent); font-style: italic; }
.doc-p a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Feature grid ---- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.15rem;
}
.feature-card {
  padding: 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--dur-hover) ease,
              transform var(--dur-ui) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  /* No lift here. Translating the element that owns the hover target slides its
     own edge out from under the pointer, drops :hover, and flickers. Colour
     alone carries the state. */
  .feature-card:hover { border-color: var(--accent-soft); }
}
.feature-card h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.5rem;
}
.feature-card h3 svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.feature-card p { font-size: 0.875rem; line-height: 1.6; color: rgba(255, 255, 255, 0.55); }

/* ---- Stack table ---- */
.stack-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
.stack-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.stack-table th, .stack-table td {
  text-align: left;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.stack-table thead th {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
.stack-table tbody tr:last-child td { border-bottom: none; }
.stack-table td:first-child { color: #fff; white-space: nowrap; font-weight: 600; }
.stack-table td:last-child { color: var(--text-2); }
.stack-table code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.12em 0.42em;
  border-radius: 4px;
}

/* ---- Gallery ---- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1.15rem;
  list-style: none;
}
.shot {
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--dur-hover) ease;
}
.shot img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 420ms var(--ease-out);
}
.shot-btn {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  cursor: zoom-in;
}
.shot figcaption {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  padding: 1.6rem 1rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.78);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
}
@media (hover: hover) and (pointer: fine) {
  /* The frame stays put; only the image inside it moves, so the hit area is
     stable and the custom cursor cannot strobe. */
  .shot:hover { border-color: var(--accent-soft); }
  .shot:hover img { transform: scale(1.05); }
  /* Caption was hover-only before, which hid it permanently on touch. It is
     always visible now; hover only lifts it slightly. */
  .shot figcaption { transition: padding-bottom var(--dur-ui) var(--ease-out); }
  .shot:hover figcaption { padding-bottom: 1rem; }
}
.shot:has(.shot-btn:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Placeholder for screenshots that are not in the repo yet. */
.shot.missing { display: grid; place-items: center; cursor: default; }
.shot.missing img, .shot.missing figcaption, .shot.missing .shot-btn { display: none; }
.shot.missing::after {
  content: 'Screenshot coming soon';
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Prev / next ---- */
.proj-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.proj-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--dur-hover) ease;
}
.proj-nav svg { width: 14px; height: 14px; transition: transform var(--dur-ui) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .proj-nav a:hover { color: var(--accent); }
  .proj-nav a.prev:hover svg { transform: translateX(-3px); }
  .proj-nav a.next:hover svg { transform: translateX(3px); }
}

/* ---- Lightbox ---------------------------------------------------------------
   Now a real dialog: role, aria-modal, focus trap, focus restore and arrow-key
   navigation. Previously it carried a hard-coded aria-hidden="true" that was
   never updated, so assistive tech could not see it even while open.
   --------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: clamp(1rem, 5vw, 3rem);
  background: rgba(4, 4, 4, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-ui) var(--ease-out),
              visibility 0s linear var(--dur-ui);
}
.lightbox.open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--dur-ui) var(--ease-out), visibility 0s;
}
.lightbox img {
  max-width: min(94vw, 1400px);
  max-height: 82vh;
  width: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  /* scale(0.97), never scale(0): nothing in the real world appears from nothing. */
  transform: scale(0.97);
  transition: transform var(--dur-ui) var(--ease-out);
}
.lightbox.open img { transform: none; }
.lightbox-caption {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-2);
  text-align: center;
}
.lightbox-count { color: var(--muted); margin-left: 0.6rem; }

.lightbox-close, .lightbox-nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  cursor: pointer;
  transition: color var(--dur-hover) ease,
              border-color var(--dur-hover) ease,
              transform var(--dur-press) var(--ease-out);
}
.lightbox-close { top: 1.25rem; right: 1.25rem; font-size: 1.35rem; line-height: 1; }
.lightbox-nav svg { width: 18px; height: 18px; }
.lightbox-nav.prev { left: 1.25rem;  top: 50%; margin-top: -22px; }
.lightbox-nav.next { right: 1.25rem; top: 50%; margin-top: -22px; }
@media (hover: hover) and (pointer: fine) {
  .lightbox-close:hover, .lightbox-nav:hover { color: var(--accent); border-color: var(--accent); }
}
.lightbox-close:active, .lightbox-nav:active { transform: scale(0.94); }
@media (max-width: 560px) {
  .lightbox-nav.prev { left: 0.5rem; }
  .lightbox-nav.next { right: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .shot:hover img { transform: none; }
  .lightbox img, .lightbox.open img { transform: none; }
}


/* ---------------------------------------------------------------------------
   Mobile budget
   -----------------------------------------------------------------------------
   Case-study pages are image-heavy, so anything that forces an extra composited
   layer or a per-scroll repaint is dropped where there is no pointer to justify
   it.
   --------------------------------------------------------------------------- */
@media (pointer: coarse), (max-width: 720px) {
  .stack-table th, .stack-table td { padding: 0.75rem 0.95rem; }
  .doc { padding-inline: 1.1rem; }
  .proj-meta { gap: 1.1rem 1.5rem; padding: 1.15rem 0; }
}
