/* Base layer: reset, the scroll-snap panel container, the panel stack and the fixed chrome
   (header, section rail, scroll cue). Colour and type come from tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
.deck-stage {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

p,
h1,
h2 {
  margin: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

/* Mobile Safari tints its toolbar from the page background, so it follows the contact
   slide to black. */
html[data-theme="ink"] {
  background: var(--ink);
}

/* The page scrolls inside this fixed, full-viewport container rather than the document,
   so mobile browser toolbars collapsing never changes the height the panels snap to. */
.panels {
  position: fixed;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.panels::-webkit-scrollbar {
  display: none;
}

/* Panels stack in document order; sections.js sets z-index so each later panel
   slides over the one before it. */
.panel {
  position: relative;
  height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--ink); /* shows around a covered panel's shrinking content */
}

/* The leading-edge shadow of a sliding panel is set per frame by sections.js. */

.panel-inner {
  position: absolute;
  inset: 0;
  transform-origin: 50% 0;
  will-change: transform;
}

.panel-shade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

/* Header */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) var(--gutter);
  /* keep "Contact" on the front photo card, clear of the stacked slivers */
  padding-right: calc(var(--gutter) + var(--active-k, 0) * var(--peek));
  pointer-events: none;
  color: var(--on-photo);
  transition: color 0.5s ease, padding-right 0.6s var(--ease-out);
}

html[data-theme="paper"] .site-header {
  color: var(--ink);
}

.site-header .wordmark,
.site-header .header-link {
  pointer-events: auto;
}

.wordmark,
.header-link {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* The studio page shows the name at full size, so the header wordmark steps back. */
.wordmark {
  transition: opacity 0.5s ease;
}

html[data-theme="paper"] .wordmark {
  opacity: 0;
  pointer-events: none;
}

/* The underline enters from the left on hover and leaves towards the right. */
.header-link {
  position: relative;
  display: inline-block;
}

.header-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.45s var(--ease-out);
}

.header-link:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Hover only where there is a real pointer; on touch it would stick after a tap. */
@media (hover: hover) {
  .header-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
  }
}

/* The contact slide is where "Contact" leads, so the link steps back there. */
.header-link {
  transition: opacity 0.5s ease;
}

html[data-theme="ink"] .header-link {
  opacity: 0;
  pointer-events: none;
}

/* Section rail */

.rail {
  position: fixed;
  left: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  color: var(--on-photo);
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.35));
  transition: color 0.5s ease, filter 0.5s ease;
}

.rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rail-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 20px;
}

.rail-tick {
  display: block;
  width: 26px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.6;
  transition: width 0.5s var(--ease-out), opacity 0.5s;
}

.rail-link:hover .rail-tick {
  width: 42px;
  opacity: 1;
}

.rail-link.is-current .rail-tick {
  width: 64px;
  opacity: 1;
}

.rail-label {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.4s, transform 0.4s var(--ease-out);
}

/* The current section is always named; hovering the rail names the rest. */
.rail-link.is-current .rail-label,
.rail:hover .rail-label,
.rail-link:focus-visible .rail-label {
  opacity: 1;
  transform: none;
}

/* Scroll cue */

.scroll-cue {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--on-photo);
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.35));
  transition: opacity 0.4s, color 0.5s ease, filter 0.5s ease;
}

html[data-theme="paper"] .scroll-cue {
  color: var(--ink);
  filter: none;
}

/* On the studio page the rail can sit over the giant name, so it inverts whatever is
   behind it: white across the black letters, black on the paper. */
html[data-theme="paper"] .rail {
  color: #fff;
  filter: none;
  mix-blend-mode: difference;
}

.scroll-cue.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.scroll-cue-label {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.scroll-cue-line {
  position: relative;
  display: block;
  width: 1px;
  height: 44px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 30%, transparent);
}

/* Short landscape screens (an iPad on its side, a small laptop): a shorter cue, so it doesn't
   crowd the studio page's lower block. */
@media (min-width: 720px) and (max-height: 820px) {
  .scroll-cue {
    gap: 8px;
  }

  .scroll-cue-line {
    height: 28px;
  }
}

.scroll-cue-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 45%;
  background: currentColor;
  animation: cue-fall 2.2s var(--ease-inout) infinite;
}

@keyframes cue-fall {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(230%);
  }
}

.scroll-cue:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 4px;
}

/* Narrow screens: ticks only. Labels stay in the accessibility tree, clipped
   out of sight, so each link still has a name. */

@media (max-width: 719px) and (min-height: 501px) {
  /* Photo decks are cards on paper here: the header sits on white above the card and the
     caption and controls below it, so the chrome is ink and nothing overlays the photo. */
  .site-header,
  html[data-theme="photo"] .site-header {
    color: var(--ink);
    padding-right: var(--gutter);
  }

  .rail {
    display: none;
  }

  /* The contact slide is white on black. */
  html[data-theme="ink"] .site-header {
    color: var(--paper);
  }

  .scroll-cue {
    color: var(--ink);
    filter: none;
  }

  .scroll-cue-line {
    height: 32px;
  }

  /* The label would crowd the project title; the moving line alone carries the cue.
     The button keeps its aria-label. */
  .scroll-cue-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .scroll-cue-line::after {
    animation: none;
  }

  html:not(.force-motion) .site-header,
  html:not(.force-motion) .wordmark,
  html:not(.force-motion) .header-link::after,
  html:not(.force-motion) .rail-tick,
  html:not(.force-motion) .rail-label,
  html:not(.force-motion) .scroll-cue {
    transition: none;
  }
}
