/* Layout of the jcpraud theme. Every value comes from tokens.css. Tasks 9 to
   11 append the module styles below the "Modules" marker. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
/* fix: audit-hallmark.md:34 verb: harden. Page-wide guard against sideways
   scroll, on top of the per-module one. clip, not hidden: no scroll
   container, so the fixed header and position: sticky keep working. */
html, body { overflow-x: clip; }
img, video { display: block; max-width: 100%; height: auto; }
main:focus { outline: none; }
p a { text-decoration: underline; text-underline-offset: 0.2em; }
a:hover, a:focus-visible { text-shadow: 0 0 12px var(--jc-red-glow); }
:focus-visible { outline: 2px solid var(--jc-red); outline-offset: 3px; }
/* fix: audit-hallmark.md:61 verb: harden. A long word in a future title
   breaks inside its box instead of widening the page. tokens.css owns the
   heading styles and is generated, so the guard lives here. */
h1, h2, h3, .section-label { overflow-wrap: anywhere; min-width: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--sp-4); top: var(--sp-4); z-index: 100;
  padding: var(--sp-2) var(--sp-4); background: var(--jc-red); color: var(--fg-on-red);
  font-weight: 700; border-radius: var(--r-md); transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* Observed by site.js (Task 9) to toggle the header background. */
.scroll-sentinel { position: absolute; top: 0; height: 100vh; width: 1px; pointer-events: none; }

/* fix: audit-impeccable.md:76 verb: adapt. Buttons, the menu toggle, filter
   labels, checkbox labels and footer links get a 44px hit area (SC 2.5.5). */
/* fix: audit-hallmark.md:55 verb: typeset. 18.66px moves into the
   --fs-button token; the filter labels below use it too. */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: var(--sp-3) var(--sp-5);
  background: var(--jc-red); color: var(--fg-on-red);
  font-size: var(--fs-button); font-weight: 700; text-decoration: none;
  border-radius: var(--r-pill); transition: box-shadow var(--dur-base) var(--ease-out);
}
.button:hover, .button:focus-visible { color: var(--fg-on-red); box-shadow: var(--glow-red); text-shadow: none; }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-3) var(--container-pad);
  transition: background var(--dur-slow) var(--ease-out);
}
.site-header.scrolled { background: var(--header-bg); backdrop-filter: var(--header-blur); }
.site-header__brand {
  font-family: var(--font-headline); letter-spacing: var(--track-wide);
  text-transform: uppercase; text-decoration: none; color: var(--fg-1); white-space: nowrap;
}
.site-header__toggle {
  font: inherit; color: var(--fg-1); background: transparent;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  min-height: 44px; padding: var(--sp-2) var(--sp-4); cursor: pointer;
}

.site-nav[popover] {
  inset: 0 0 auto auto; margin: 0; width: min(20rem, 100vw); min-height: 100vh;
  padding: var(--sp-9) var(--sp-6); border: 0;
  background: var(--bg-overlay); backdrop-filter: var(--header-blur); color: var(--fg-1);
}
.site-nav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-4); }
.site-nav__list a {
  color: var(--fg-1); text-decoration: none;
  font-family: var(--font-headline); font-size: var(--fs-body-sm);
  letter-spacing: var(--track-wide); text-transform: uppercase; white-space: nowrap;
}

/* The six links need about 1410px beside the brand: below that, the menu
   stays behind the toggle rather than wrapping onto two lines. */
@media (min-width: 1440px) {
  .site-header__toggle { display: none; }
  .site-nav[popover], .site-nav[popover]:not(:popover-open) {
    display: block; position: static; inset: auto; width: auto; min-height: 0;
    padding: 0; background: none; backdrop-filter: none; overflow: visible;
  }
  .site-nav__list { display: flex; gap: var(--sp-5); }
}

/* ---------- Simple pages ---------- */
.page {
  max-width: 72ch; margin: 0 auto;
  padding: var(--sp-10) var(--container-pad) var(--sp-8);
}
.page__title { font-size: var(--fs-h1); }

/* ---------- Footer ---------- */
.site-footer {
  display: grid; gap: var(--sp-6);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  padding: var(--sp-8) var(--container-pad);
  background: var(--bg-page-deep); border-top: 1px solid var(--border-hairline);
}
.site-footer__title { font-size: var(--fs-h4); }
.site-footer__list { list-style: none; margin: 0; padding: 0; display: grid; }
.site-footer__list a { display: inline-flex; align-items: center; min-height: 44px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Modules ---------- */

/* Anchors clear the fixed header. */
.module, .service { scroll-margin-top: var(--sp-9); }
/* overflow-x: clip keeps side reveals from widening the page before they run. */
.module { padding: var(--sp-7) var(--container-pad); overflow-x: clip; }
@media (min-width: 900px) { .module { padding-block: var(--sp-9); } }

/* Section label with the 56px red hairline (README, Layout rules). */
.section-label { text-align: center; }
.section-label::after {
  content: ""; display: block; width: 56px; height: 1px;
  margin: var(--sp-4) auto 0; background: var(--jc-red);
}

/* Pages without a hero: the header turns solid as soon as the page scrolls. */
body:not(:has(.module--hero)) .scroll-sentinel { height: 1px; }

/* Animation 1: reveals from below or from the sides. Hidden only when
   site.js can reveal them and motion is allowed. */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .reveal { transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
  .reveal:not(.is-visible) { opacity: 0; transform: translateY(12px); }
  .reveal--left:not(.is-visible) { transform: translateX(-24px); }
  .reveal--right:not(.is-visible) { transform: translateX(24px); }
}

/* Pause toggle shared by the marquee and the decorative videos: two bars,
   a play triangle once pressed. */
.pause-toggle {
  position: absolute; right: var(--sp-3); bottom: var(--sp-3); z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  color: var(--fg-1); background: var(--bg-overlay);
  border: 1px solid var(--border-strong); border-radius: var(--r-pill); cursor: pointer;
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.pause-toggle[hidden] { display: none; }
.pause-toggle:hover, .pause-toggle:focus-visible { box-shadow: var(--glow-red); }
.pause-toggle__icon {
  box-sizing: content-box; width: 4px; height: 14px;
  border-inline: 4px solid currentColor;
}
.pause-toggle[aria-pressed="true"] .pause-toggle__icon {
  width: 0; height: 0; margin-left: 4px;
  border-inline: 0; border-left: 12px solid currentColor; border-block: 7px solid transparent;
}

/* Decorative videos */
.deco-video { position: relative; margin: 0; }
.deco-video video { width: 100%; border-radius: var(--r-md); }

/* Hero */
/* fix: audit-hallmark.md:19 verb: layout. Bottom padding 1.33 times the
   top at every width (was 0.375 on mobile, 0.75 on desktop). 96px on top
   still clears the fixed header (68px on mobile, 49px on desktop). */
.module--hero {
  position: relative; display: grid; align-items: end; min-height: 100svh;
  padding-block: var(--sp-9) var(--sp-10); overflow: hidden;
}
.hero__video { position: absolute; inset: 0; }
.hero__video video { height: 100%; object-fit: cover; border-radius: 0; }
.hero__video::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg-page) 0%, transparent 60%);
}
/* fix: audit-impeccable.md:110 verb: typeset. 64rem keeps the h1 on two
   lines from 900px up to the 72px ceiling of --fs-display-md (48rem wrapped
   it on four). At 390px the four lines stay: one word alone is 252px of
   the 350px measure. */
.hero__body { position: relative; z-index: 1; max-width: 64rem; }

/* Animation 3: keyword marquee. Each track slides by its own width and ends
   with a gap, so the second track takes over seamlessly. */
.module--marquee {
  position: relative; padding-inline: 0; overflow: hidden;
  border-block: 1px solid var(--border-hairline);
}
.marquee__viewport { display: flex; width: max-content; }
.marquee__track {
  display: flex; flex-shrink: 0; gap: var(--sp-7);
  margin: 0; padding: 0 var(--sp-7) 0 0; list-style: none;
  animation: marquee var(--marquee-duration) linear infinite;
}
.marquee__track li {
  font-family: var(--font-headline); font-size: var(--fs-h3);
  letter-spacing: var(--track-wide); text-transform: uppercase; white-space: nowrap;
}
.module--marquee:hover .marquee__track,
.module--marquee:focus-within .marquee__track,
.module--marquee.is-paused .marquee__track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* Services */
.service { max-width: var(--container-max); margin: 0 auto var(--sp-8); }
.service__title { text-align: center; }
.service__group { display: grid; gap: var(--sp-5); margin-bottom: var(--sp-7); }
.service__media {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
.service__img, .service__video video {
  width: 100%; height: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--r-md);
}
/* fix: audit-impeccable.md:67 verb: typeset. 65-75 characters per line
   (720px gave about 102 at 1440px). Eurostile's "0" is wide: 1ch is about
   1.45 average characters, so 48ch measures a median of 67, at most 74. */
.service__text { max-width: 48ch; margin: 0 auto; }

/* About */
.about { display: grid; gap: var(--sp-6); align-items: center; max-width: var(--container-max); margin: 0 auto; }
/* fix: audit-hallmark.md:27 verb: harden. minmax(0, 1fr): a bare 1fr
   track floors at its content's min width, so a wide video could push
   the text column. */
@media (min-width: 900px) {
  .about { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
/* fix: audit-impeccable.md:67 verb: typeset. Same measure as the services
   (the 646px column gave about 94 characters at 1440px). */
.about__text { max-width: 48ch; }

@media (prefers-reduced-motion: reduce) {
  .marquee__track { animation: none; flex-wrap: wrap; justify-content: center; }
  .marquee__track[aria-hidden="true"] { display: none; }
  .marquee__viewport { width: auto; }
  .module--marquee .pause-toggle { display: none; }
}

/* Portfolio filter: each label is the visible face of a hidden radio. The
   per-category hiding rules are generated by portfolio.html.twig. */
.portfolio__filter {
  display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-3);
  margin: 0 auto var(--sp-7); padding: 0; border: 0; max-width: var(--container-max);
}
/* fix: audit-impeccable.md:57 verb: colorize. Snow on red is 3.85:1, so the
   checked label must be large text: bold 18.66px, as the button (design §6).
   Every label gets it, so checking one does not change its width. */
.portfolio__filter label {
  display: flex; align-items: center; min-height: 44px;
  padding: var(--sp-2) var(--sp-4); cursor: pointer;
  font-size: var(--fs-button); font-weight: 700;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.portfolio__filter label:hover { box-shadow: var(--glow-red); }
.portfolio__filter input:checked + label { background: var(--jc-red); border-color: var(--jc-red); color: var(--fg-on-red); }
.portfolio__filter input:focus-visible + label { outline: 2px solid var(--jc-red); outline-offset: 3px; }

/* Grid: CSS columns, so the photos read column by column in media_order. */
.portfolio__grid {
  column-count: 2; column-gap: var(--sp-3);
  max-width: var(--container-max); margin: 0 auto; padding: 0; list-style: none;
}
@media (min-width: 700px) { .portfolio__grid { column-count: 3; } }
@media (min-width: 1200px) { .portfolio__grid { column-count: 4; } }
.tile { break-inside: avoid; margin-bottom: var(--sp-3); }
.tile__button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.tile__img { width: 100%; border-radius: var(--r-md); transition: box-shadow var(--dur-base) var(--ease-out); }
.tile__button:hover .tile__img, .tile__button:focus-visible .tile__img { box-shadow: var(--glow-red); }

/* Animation 4: tiles appear one after the other once the grid is on screen.
   The delay stops growing after 12 tiles, so the last ones do not lag. */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  [data-stagger] .tile {
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
    transition-delay: calc(min(var(--i), 12) * var(--stagger-step));
  }
  [data-stagger]:not(.is-visible) .tile { opacity: 0; transform: translateY(12px); }
}

/* Animations 8 and 9: the lightbox fades in and out over a dark backdrop,
   without blur. It fills the viewport; the photo fits inside the padding,
   which keeps the close button clear of it. */
.lightbox {
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: var(--sp-9) var(--sp-3); border: 0;
  background: transparent; color: var(--fg-1); touch-action: pan-y pinch-zoom;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out),
    overlay var(--dur-base) allow-discrete, display var(--dur-base) allow-discrete;
}
.lightbox[open] { display: grid; place-items: center; opacity: 1; }
@starting-style { .lightbox[open] { opacity: 0; } }
.lightbox::backdrop { background: var(--bg-overlay); }
.lightbox__img {
  width: auto; max-width: 100%; max-height: calc(100dvh - 2 * var(--sp-9));
  object-fit: contain; border-radius: var(--r-md);
}
.lightbox__close, .lightbox__prev, .lightbox__next {
  position: absolute; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  font-size: var(--fs-h4); line-height: 1; color: var(--fg-1); background: var(--bg-overlay);
  border: 1px solid var(--border-strong); border-radius: var(--r-pill); cursor: pointer;
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.lightbox__close:hover, .lightbox__prev:hover, .lightbox__next:hover,
.lightbox__close:focus-visible, .lightbox__prev:focus-visible, .lightbox__next:focus-visible { box-shadow: var(--glow-red); }
.lightbox__close { top: var(--sp-4); right: var(--sp-4); }
.lightbox__prev, .lightbox__next { top: 50%; translate: 0 -50%; }
.lightbox__prev { left: var(--sp-3); }
.lightbox__next { right: var(--sp-3); }

/* Contact: logo, title and office photo, then the form, then the piano photo,
   as on the Django page. */
.module--contact { display: grid; justify-items: center; gap: var(--sp-6); }
.contact__head { display: grid; justify-items: center; gap: var(--sp-5); max-width: 800px; }
.contact__logo { width: 96px; height: auto; }
.contact__office, .contact__piano { width: 100%; border-radius: var(--r-md); }
.contact__piano { max-width: 600px; }
.contact__form { width: 100%; max-width: 40rem; }

/* Form plugin markup (built_in_css is off). The Cap field has no visible
   part: its wrapper and empty label leave the layout. */
/* fix: audit-impeccable.md:48 verb: colorize. Field and fieldset outlines
   use --fg-3, opaque: 3.68:1 on --bg-surface and 3.91:1 on the page (SC 1.4.11). */
.contact__form form { display: grid; gap: var(--sp-5); }
.contact__form .form-field:has(.cap-container) { display: none; }
.contact__form .form-label { margin-bottom: var(--sp-2); }
.contact__form .required { color: var(--jc-red); }
.contact__form input:not([type="checkbox"], [type="hidden"], .form-honeybear), .contact__form textarea {
  width: 100%; padding: var(--sp-3) var(--sp-4);
  font: inherit; color: var(--fg-1); background: var(--bg-surface);
  border: 1px solid var(--fg-3); border-radius: var(--r-md);
}
.contact__form textarea { min-height: 10rem; resize: vertical; }
.contact__form input[type="date"] { color-scheme: dark; }
.contact__form fieldset { margin: 0; padding: var(--sp-4); border: 1px solid var(--fg-3); border-radius: var(--r-md); }
.contact__form legend { padding-inline: var(--sp-2); }
/* Each box and its label share a grid row. */
.contact__form .checkboxes { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--sp-3); }
/* !important: the form plugin writes display: inline on each label. */
.contact__form .checkboxes label { display: flex !important; align-items: center; min-height: 44px; cursor: pointer; }
.contact__form input[type="checkbox"] { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--jc-red); }
.contact__form .form-display-wrapper p { margin: 0; font-size: var(--fs-body-sm); color: var(--fg-2); }
.contact__form .has-errors input, .contact__form .has-errors textarea { border-color: var(--status-danger); }
.contact__form .form-errors .form-message { margin: var(--sp-2) 0 0; font-size: var(--fs-body-sm); color: var(--fg-1); }
.contact__form .buttons { justify-self: center; }
.contact__form .button { border: 0; cursor: pointer; font-family: inherit; }
.notices {
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border-red); border-radius: var(--r-md);
  margin-bottom: var(--sp-5); background: var(--bg-surface-raised);
}
.notices p { margin: 0; }

/* Legal pages: section headings one step below the page title, and the
   publisher and host as two-column lists sharing one label width. */
.legal-identity, .legal-section { margin-top: var(--sp-7); }
.legal-identity h2, .legal-section h2 { font-size: var(--fs-h3); }
.legal-identity__list { display: grid; grid-template-columns: 11rem 1fr; gap: var(--sp-2) var(--sp-5); margin: 0 0 var(--sp-6); }
.legal-identity__list dt { color: var(--fg-2); }
.legal-identity__list dd { margin: 0; }
@media (max-width: 599px) {
  .legal-identity__list { grid-template-columns: 1fr; gap: 0; }
  .legal-identity__list dd { margin-bottom: var(--sp-3); }
}
[data-missing] { color: var(--fg-3); font-style: italic; }

/* /merci: the drone video, then the way back home. */
.page__video { margin-top: var(--sp-6); }
.page__back { margin-top: var(--sp-6); text-align: center; }

/* fix: audit-hallmark.md:86 verb: animate. Press state from the design
   system README: every pill control scales to 0.97 over --dur-fast, and
   red ones darken to --jc-red-deep. scale, not transform, so the
   lightbox arrows keep their translate. Kept last to win the cascade. */
.button, .site-header__toggle, .pause-toggle, .portfolio__filter label,
.lightbox__close, .lightbox__prev, .lightbox__next {
  transition: box-shadow var(--dur-base) var(--ease-out),
    scale var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.button:active, .site-header__toggle:active, .pause-toggle:active, .portfolio__filter label:active,
.lightbox__close:active, .lightbox__prev:active, .lightbox__next:active { scale: 0.97; }
.button:active, .portfolio__filter input:checked + label:active { background-color: var(--jc-red-deep); }
