/* ==========================================================================
   Shell: panel stack, header, menu overlay, cursor, progress rail
   ========================================================================== */

/* --------------------------------------------------------------------------
   The stack. Panels are absolutely positioned inside a fixed viewport box and
   transformed by the scroll engine, so the document height never changes.
   -------------------------------------------------------------------------- */

.stack {
  position: fixed;
  inset: 0;
  z-index: var(--z-stack);
  overflow: hidden;
  background: var(--page-surface, #000);
  transition: padding 0.6s var(--ease-out), background 0.6s var(--ease-out);
}

/* In light mode the stack pulls in from the edges and the panels become a
   rounded card floating on the page surface. */
:root[data-theme="light"] .stack {
  padding: 6.6rem var(--page-x) var(--page-x);
}

:root[data-theme="light"] .panel {
  border-radius: var(--border-radius-lg);
}

/* The panels clip their own media, so the radius has to reach the children. */
:root[data-theme="light"] .panel__inner,
:root[data-theme="light"] .hero__media,
:root[data-theme="light"] .case__media {
  border-radius: inherit;
  overflow: hidden;
}

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  transform: translate3d(0, 100%, 0);
  will-change: transform;
  backface-visibility: hidden;
}

/* Panels outside the active window are pulled from the paint path entirely. */
.panel[data-dormant="true"] { visibility: hidden; }

/* The inner wrapper takes the counter-transform that produces the parallax
   of an outgoing panel sliding slower than the one covering it. */
.panel__inner {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  will-change: transform, filter;
}

/* Every panel that is not the first gets a soft top edge as it rises. */
.panel--rounded { border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0; }

/* A shade that darkens a panel while it is being covered. */
.panel__shade {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: #000;
  opacity: 0;
}

.panel-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--gutter) * 5) calc(var(--page-x) + var(--rail-space)) calc(var(--gutter) * 3) var(--page-x);
  min-height: 0;
}

/* Shared 12-column grid, gutter-aligned with the header. */
.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gutter);
  width: 100%;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: var(--z-header);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--gutter);
  padding: var(--header-y) var(--page-x);
  mix-blend-mode: normal;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}

.header__left { justify-self: start; }
.header__center { justify-self: center; }
.header__right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: var(--gutter-xs);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.wordmark__mark {
  height: 1.4rem;
  width: auto;
  object-fit: contain;
}

/* Two tinted copies of the mark; whichever suits the surface is shown. */
.wordmark__mark--dark { display: none; }
:root[data-theme="light"] .header:not([data-over="dark"]) .wordmark__mark--light { display: none; }
:root[data-theme="light"] .header:not([data-over="dark"]) .wordmark__mark--dark { display: block; }

.wordmark__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--purple);
  transform: translateY(-0.15em);
}

.clock {
  font-size: var(--fs-small);
  color: var(--text-regular);
  white-space: nowrap;
}

/* Header inverts against light panels. */
.header.is-inverted .wordmark,
.header.is-inverted .clock { color: #000; }
.header.is-inverted .btn { background: hsla(0, 0%, 40%, 0.14); color: #000; }
.header.is-inverted .btn:hover { background: hsla(0, 0%, 0%, 0.1); }
.header.is-inverted .menu-toggle__bar { background: #000; }

/* Hero, case and accent panels are dark artwork in either theme, so their
   contents keep the dark-theme token set. */
:root[data-theme="light"] .panel[data-surface="dark"] {
  --fg: #fff;
  --text-bold: #fff;
  --text-regular: #cac5ca;
  --text-subtle: #aeaaae;
  --border-subtle: #313033;
  --button-bg: hsla(0, 0%, 73%, 0.2);
  color: #fff;
}

/* Header chrome follows whatever panel is under it, not the page theme. */
:root[data-theme="light"] .header[data-over="dark"] .wordmark,
:root[data-theme="light"] .header[data-over="dark"] .clock { color: #fff; }
:root[data-theme="light"] .header[data-over="dark"] .btn {
  background: hsla(0, 0%, 73%, 0.2);
  color: #fff;
}
:root[data-theme="light"] .header[data-over="dark"] .btn:hover { background: hsla(0, 0%, 100%, 0.28); }
:root[data-theme="light"] .header[data-over="dark"] .menu-toggle__bar { background: #fff; }
:root[data-theme="light"] .header[data-over="dark"] ~ .rail .rail__dot { background: hsla(0, 0%, 100%, 0.3); }
:root[data-theme="light"] .header[data-over="dark"] ~ .rail .rail__dot.is-active { background: #fff; }
:root[data-theme="light"] .header[data-over="dark"] ~ .scroll-hint { color: hsla(0, 0%, 100%, 0.7); }

:root[data-theme="light"] .header .wordmark,
:root[data-theme="light"] .header .clock { color: #000; }
:root[data-theme="light"] .header .btn { background: hsla(0, 0%, 45%, 0.14); color: #000; }
:root[data-theme="light"] .header .btn:hover { background: hsla(0, 0%, 0%, 0.1); }
:root[data-theme="light"] .menu-toggle__bar { background: #000; }
:root[data-theme="light"] .rail__dot { background: hsla(0, 0%, 0%, 0.22); }
:root[data-theme="light"] .rail__dot.is-active { background: #000; }
:root[data-theme="light"] .scroll-hint { color: hsla(0, 0%, 0%, 0.55); }
:root[data-theme="light"] .cursor { border-color: hsla(0, 0%, 0%, 0.6); }

/* Over the accent panel the purple dot would vanish into the background. */
.header.is-accent .wordmark__dot { background: #fff; }

/* Menu toggle: two bars that cross into an X while the overlay is open. */
.menu-toggle { display: inline-flex; align-items: center; gap: 0.8rem; }

.menu-toggle__bars {
  position: relative;
  width: 1.4rem;
  height: 0.9rem;
  flex: none;
}

.menu-toggle__bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: #fff;
  transition: transform var(--dur) var(--ease-out);
}
.menu-toggle__bar:nth-child(1) { top: 0; }
.menu-toggle__bar:nth-child(2) { bottom: 0; }

.is-menu-open .menu-toggle__bar:nth-child(1) { transform: translateY(0.4rem) rotate(45deg); }
.is-menu-open .menu-toggle__bar:nth-child(2) { transform: translateY(-0.4rem) rotate(-45deg); }

/* --------------------------------------------------------------------------
   Menu overlay

   Three zones, as on the reference: navigation and work on the left, a
   standing portrait stage in the middle, and a dismissible news stack on the
   right. The overlay is light in either theme — it is a different surface,
   not a darker version of the page.
   -------------------------------------------------------------------------- */

.menu {
  position: fixed;
  inset: 0;
  z-index: var(--z-menu);
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) auto minmax(16rem, 1fr);
  align-items: center;
  gap: var(--gutter);
  padding: 8rem var(--page-x) var(--page-x);
  background: #fff;
  color: #000;
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, -100%, 0);
  transition:
    transform 0.9s var(--ease-out),
    opacity 0.5s var(--ease-out),
    visibility 0s linear 0.9s;
}

.is-menu-open .menu {
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0);
  transition:
    transform 0.9s var(--ease-out),
    opacity 0.3s var(--ease-out),
    visibility 0s linear 0s;
}

/* The header sits above the overlay and has to read against white. */
.is-menu-open .header .wordmark,
.is-menu-open .header .clock { color: #000; }
.is-menu-open .header .wordmark__mark--light { display: none; }
.is-menu-open .header .wordmark__mark--dark { display: block; }
.is-menu-open .header .btn { background: hsla(0, 0%, 45%, 0.14); color: #000; }
.is-menu-open .header .btn:hover { background: hsla(0, 0%, 0%, 0.1); }
.is-menu-open .menu-toggle__bar { background: #000; }

.menu__col { min-width: 0; align-self: center; }
.menu__col--nav { justify-self: start; }
.menu__col--news { justify-self: end; }

/* ---- navigation ------------------------------------------------------- */

.menu__links {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 4rem;
}

.menu__link {
  display: inline-block;
  width: fit-content;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.2rem, 1.7vw, 3rem);
  line-height: 1.32;
  letter-spacing: var(--ls-display);
  color: #000;
  opacity: 0;
  transform: translateY(0.8rem);
  transition:
    opacity 0.5s var(--ease-out),
    transform 0.5s var(--ease-out),
    color var(--dur-fast) linear;
}

.is-menu-open .menu__link { opacity: 1; transform: none; }
.is-menu-open .menu__link:nth-child(1) { transition-delay: 0.16s; }
.is-menu-open .menu__link:nth-child(2) { transition-delay: 0.21s; }
.is-menu-open .menu__link:nth-child(3) { transition-delay: 0.26s; }
.is-menu-open .menu__link:nth-child(4) { transition-delay: 0.31s; }

/* Pointing at one entry recedes the others. */
.menu__links:hover .menu__link { color: var(--neutral-70); }
.menu__links .menu__link:hover { color: #000; }

.menu__label { color: var(--neutral-50); margin-bottom: 1.2rem; }

.menu__work {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: 26rem;
}

.menu__work .btn {
  background: #f0f0f2;
  color: #000;
  opacity: 0;
  transform: translateY(0.6rem);
  transition:
    opacity 0.45s var(--ease-out),
    transform 0.45s var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.menu__work .btn:hover { background: #e2e2e6; border-color: transparent; }
.is-menu-open .menu__work .btn { opacity: 1; transform: none; }
.is-menu-open .menu__work .btn:nth-child(1) { transition-delay: 0.3s; }
.is-menu-open .menu__work .btn:nth-child(2) { transition-delay: 0.34s; }
.is-menu-open .menu__work .btn:nth-child(3) { transition-delay: 0.38s; }
.is-menu-open .menu__work .btn:nth-child(4) { transition-delay: 0.42s; }
.is-menu-open .menu__work .btn:nth-child(5) { transition-delay: 0.46s; }
.is-menu-open .menu__work .btn:nth-child(6) { transition-delay: 0.5s; }
.is-menu-open .menu__work .btn:nth-child(7) { transition-delay: 0.54s; }

/* ---- centre stage ------------------------------------------------------ */

.menu__stage {
  position: relative;
  justify-self: center;
  height: min(80vh, 78rem);
  aspect-ratio: 2 / 3;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: #000;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

.is-menu-open .menu__stage { opacity: 1; transform: none; transition-delay: 0.12s; }

.menu__loop,
.menu__still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu__still {
  opacity: 0;
  transform: scale(1.03);
  transition: opacity var(--dur) var(--ease-out), transform 0.6s var(--ease-out);
}

.menu__stage.is-showing .menu__still { opacity: 1; transform: none; }

/* ---- news stack -------------------------------------------------------- */

.news {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(19rem, 100%);
  margin-left: auto;
}

.news__card {
  position: relative;
  padding: 1.2rem;
  border-radius: var(--border-radius);
  background: #f4f4f6;
  opacity: 0;
  transform: translateX(1.2rem);
  transition:
    opacity 0.5s var(--ease-out),
    transform 0.5s var(--ease-out);
}

.is-menu-open .news__card { opacity: 1; transform: none; }
.is-menu-open .news__card:nth-child(1) { transition-delay: 0.24s; }
.is-menu-open .news__card:nth-child(2) { transition-delay: 0.3s; }
.is-menu-open .news__card:nth-child(3) { transition-delay: 0.36s; }
.is-menu-open .news__card:nth-child(4) { transition-delay: 0.42s; }
.is-menu-open .news__card:nth-child(5) { transition-delay: 0.48s; }

/* Dismissed cards collapse out of the stack. */
.news__card.is-dismissed {
  opacity: 0;
  transform: translateX(2rem);
  margin-top: -0.4rem;
  max-height: 0;
  padding-block: 0;
  overflow: hidden;
  transition:
    opacity 0.3s var(--ease-out),
    transform 0.3s var(--ease-out),
    max-height 0.45s var(--ease-out) 0.1s,
    padding 0.45s var(--ease-out) 0.1s,
    margin 0.45s var(--ease-out) 0.1s;
}

.news__close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--neutral-50);
  transition: background var(--dur-fast) linear, color var(--dur-fast) linear;
}

.news__close:hover { background: hsla(0, 0%, 0%, 0.06); color: #000; }

.news__title,
.news__text { font-size: 1.3rem; line-height: 1.35; color: #000; }
.news__date { color: var(--neutral-50); margin-bottom: 0.8rem; }
.news__title { margin-bottom: 1rem; padding-right: 2rem; }

.news__media {
  border-radius: 0.4rem;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: #000;
}

.news__media--tall { aspect-ratio: 3 / 4; }
.news__media img,
.news__media video { width: 100%; height: 100%; object-fit: cover; }

.news__row { display: flex; gap: 1rem; align-items: flex-start; }

.news__badge {
  flex: none;
  width: 3.6rem;
  height: 3.6rem;
  display: grid;
  place-items: center;
  border-radius: 0.4rem;
  background: #000;
  color: #fff;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
}

.news__badge--accent { background: var(--purple); }

.news__text { padding-right: 1.2rem; }

/* ---- footer meta ------------------------------------------------------- */

.menu__meta {
  position: absolute;
  left: var(--page-x);
  bottom: var(--page-x);
  display: flex;
  gap: 2.4rem;
}

.menu__meta .label { color: var(--neutral-50); }

@media (max-width: 940px) {
  .menu { grid-template-columns: 1fr; align-content: start; overflow-y: auto; }
  .menu__stage,
  .menu__col--news { display: none; }
  .menu__col--nav { justify-self: stretch; }
  .menu__link { font-size: clamp(3rem, 6vw, 4.8rem); }
  .menu__work { flex-direction: row; flex-wrap: wrap; max-width: none; }
  .menu__meta { position: static; margin-top: 4rem; }
}

/* --------------------------------------------------------------------------
   Scroll progress rail + section indicator
   -------------------------------------------------------------------------- */

.rail {
  position: fixed;
  right: var(--page-x);
  top: 50%;
  transform: translateY(-50%);
  z-index: calc(var(--z-header) - 1);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.rail__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsla(0, 0%, 100%, 0.28);
  transition:
    background var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
  cursor: pointer;
}

.rail__dot.is-active {
  background: #fff;
  transform: scale(1.7);
}

/* The overlay owns the screen while it is open. */
.is-menu-open .rail,
.is-menu-open .scroll-hint { opacity: 0; pointer-events: none; }

.rail { transition: opacity var(--dur) var(--ease-out); }

.header.is-inverted ~ .rail .rail__dot { background: hsla(0, 0%, 0%, 0.25); }
.header.is-inverted ~ .scroll-hint { color: hsla(0, 0%, 0%, 0.6); }
.header.is-inverted ~ .rail .rail__dot.is-active { background: #000; }

/* Bottom-left scroll hint, fades out after the first input. */
.scroll-hint {
  color: hsla(0, 0%, 100%, 0.7);
  position: fixed;
  left: var(--page-x);
  bottom: var(--page-x);
  z-index: calc(var(--z-header) - 1);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: opacity var(--dur) var(--ease-out);
}

.has-scrolled .scroll-hint { opacity: 0; pointer-events: none; }

.scroll-hint__line {
  width: 3.2rem;
  height: 1px;
  background: currentColor;
  transform-origin: left center;
  animation: hint 2.4s var(--ease-in-out) infinite;
}

@keyframes hint {
  0%, 100% { transform: scaleX(0.3); opacity: 0.4; }
  50% { transform: scaleX(1); opacity: 1; }
}

/* --------------------------------------------------------------------------
   Custom cursor
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   Cursor

   Two concentric circles in one SVG, as on the reference: a small filled dot
   marking the true pointer position, and a hairline ring that opens up over
   anything interactive and turns to the highlight colour. Radii animate, so
   there is a single element rather than a stack of divs.
   -------------------------------------------------------------------------- */

.has-custom-cursor,
.has-custom-cursor * { cursor: none !important; }

.cursor {
  --circle-size: 9.6rem;
  --cursor-fg: #fff;
  --ring-color: var(--cursor-fg);
  position: fixed;
  top: 0;
  left: 0;
  width: var(--circle-size);
  height: var(--circle-size);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-cursor);
  pointer-events: none;
  opacity: 0;
  backface-visibility: hidden;
  transition: opacity var(--dur) var(--ease-out);
}

.cursor.is-visible { opacity: 1; }

.cursor__svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--circle-size);
  height: var(--circle-size);
  transform: translate(-50%, -50%);
  overflow: visible;
}

.cursor__ring {
  stroke: var(--ring-color);
  vector-effect: non-scaling-stroke;
  transition: stroke 0.2s linear, r 0.42s var(--ease-out);
}

.cursor__dot {
  fill: var(--cursor-fg);
  transition: fill 0.2s linear, r 0.42s var(--ease-out);
}

/* Over something clickable the ring takes the brand colour, exactly as the
   reference does for its FOCUS state. */
.cursor[data-state="focus"],
.cursor[data-state="label"] { --ring-color: var(--bg-highlight); }

.cursor__text {
  position: relative;
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--cursor-fg);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(0.3rem);
  transition: opacity 0.2s linear, transform 0.3s var(--ease-out);
}

.cursor[data-state="label"] .cursor__text { opacity: 1; transform: none; }

/* The cursor carries its own light/dark token, decided by the surface it is
   currently over rather than by the page theme alone. */
:root[data-theme="light"] .cursor { --cursor-fg: #000; }
.cursor[data-surface="dark"] { --cursor-fg: #fff; }
.is-menu-open .cursor { --cursor-fg: #000; }

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
  .has-custom-cursor,
  .has-custom-cursor * { cursor: auto !important; }
}


/* --------------------------------------------------------------------------
   Responsive shell
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .menu { grid-template-columns: 1fr; }
  .menu__col--primary { border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  .menu__preview { display: none; }
  .menu__meta { position: static; margin-top: 2.4rem; }
  .rail { display: none; }
  .panel-content { padding: calc(var(--gutter) * 5) var(--gutter) calc(var(--gutter) * 4); }
}

@media (max-width: 640px) {
  .header__right .clock { display: none; }
}

/* --------------------------------------------------------------------------
   No-JS / reduced-motion fallback: panels return to normal document flow so
   the page is a plain, scrollable, readable document.
   -------------------------------------------------------------------------- */

.no-stack .stack { position: static; overflow: visible; }
.no-stack .panel {
  position: relative;
  inset: auto;
  transform: none !important;
  min-height: 100vh;
}
.no-stack .panel__inner { transform: none !important; filter: none !important; }
.no-stack .panel__shade { display: none; }
.no-stack body { overflow: auto; }
.no-stack .rail,
.no-stack .scroll-hint { display: none; }

/* --------------------------------------------------------------------------
   Theme toggle icon swap
   -------------------------------------------------------------------------- */

.icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: block; }
