/* ============================================================
   Barcelona — styles
   1. Tokens      2. Base        3. Deck mechanics
   4. Media       5. Type        6. Slides
   7. Chrome      8. Motion / breakpoints
   ============================================================ */

/* ── 1. Tokens ─────────────────────────────────────────────── */
:root {
  /* colour */
  --cream:        #F4EFE6;
  --ink:          #14120F;
  --muted:        #7C7268;
  --accent:       #BE4A2C;          /* restrained warm red */
  --line:         rgba(20, 18, 15, .16);

  --on-dark:      #F6F1E8;
  --on-dark-mute: rgba(246, 241, 232, .60);
  --line-dark:    rgba(246, 241, 232, .22);

  /* type */
  --serif: "Instrument Serif", ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* scale */
  --t-display: clamp(3.6rem, 17.5vw, 9rem);
  --t-title:   clamp(2.4rem, 11vw, 4.6rem);
  --t-state:   clamp(1.75rem, 7.6vw, 3.1rem);
  --t-line:    clamp(1.5rem, 6.6vw, 2.6rem);
  --t-body:    clamp(1rem, 4.2vw, 1.15rem);
  --t-small:   clamp(.8125rem, 3.4vw, .9rem);
  --t-label:   .6875rem;

  /* rhythm */
  --pad-x:  clamp(24px, 6.6vw, 88px);
  --pad-y:  clamp(30px, 6vw, 72px);
  --chrome: 44px;                    /* space reserved for progress ticks */

  /* motion */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --fade: 780ms;
}

/* ── 2. Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
}

body {
  font-family: var(--sans);
  color: var(--on-dark);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

.noscript {
  position: fixed; inset: 0; display: grid; place-content: center;
  padding: 2rem; font-size: 1rem; color: var(--on-dark); text-align: center;
}

/* ── 3. Deck mechanics ─────────────────────────────────────── */
.deck {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  outline: none;
}

.slide {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--fade) var(--ease), visibility 0s linear var(--fade);
}

/* Incoming slide fades in on top of the outgoing one — no background flash. */
.slide.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  transition: opacity var(--fade) var(--ease), visibility 0s;
}
.slide.is-prev {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: none;
}

.slide--hero, .slide--city, .slide--end { --photo-mute: rgba(246, 241, 232, .82); }
.slide--hero .lede, .slide--city .tags, .slide--end .lede { color: var(--photo-mute); }

.slide[data-theme="dark"]  { background: var(--ink);   color: var(--on-dark); --fg-mute: var(--on-dark-mute); --rule: var(--line-dark); }
.slide[data-theme="light"] { background: var(--cream); color: var(--ink);     --fg-mute: var(--muted);        --rule: var(--line); }

/* Layout frame — every slide's content lives in one of these. */
.frame {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1220px;
  height: 100%;
  margin: 0 auto;
  padding:
    calc(var(--pad-y) + env(safe-area-inset-top))
    calc(var(--pad-x) + env(safe-area-inset-right))
    calc(var(--pad-y) + var(--chrome) + env(safe-area-inset-bottom))
    calc(var(--pad-x) + env(safe-area-inset-left));
}
.frame--end     { justify-content: flex-end; }
.frame--center  { justify-content: center; }
.frame--between { justify-content: space-between; }
.frame--mid     { justify-content: center; align-items: center; text-align: center; }
.frame--tight   { --pad-y: clamp(26px, 5vw, 60px); }

/* Staggered reveal. Index/delay is assigned in script.js. */
[data-reveal] {
  opacity: 0;
  transform: translateY(var(--rise, 16px));
  transition:
    opacity .9s var(--ease) var(--delay, 0ms),
    transform .9s var(--ease) var(--delay, 0ms);
}
.slide.is-active [data-reveal],
.slide.is-prev   [data-reveal] { opacity: 1; transform: none; }
.slide:not(.is-active):not(.is-prev) [data-reveal] { transition: none; }
.deck[data-dir="back"] [data-reveal] { --rise: -14px; }

/* ── 4. Media + placeholders ───────────────────────────────── */
.media {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--ph-bg, #2A2622);
}
.media--fill { position: absolute; inset: 0; z-index: 0; }

.media__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  opacity: 0;
  transition: opacity .6s ease;
}
.media.has-image .media__img { opacity: 1; }

/* Very slow drift on the active slide's photography. */
.slide.is-active .media.has-image .media__img { animation: drift 18s var(--ease) forwards; }
@keyframes drift { from { transform: scale(1.055); } to { transform: scale(1); } }

/* Placeholder — visible until the real file exists, then it fades away. */
.media__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--ph-ink, rgba(246, 241, 232, .92));
  background:
    repeating-linear-gradient(45deg,
      rgba(255, 255, 255, .045) 0 1px,
      transparent 1px 9px);
  transition: opacity .4s ease;
}
.media.has-image .media__ph { opacity: 0; pointer-events: none; }

.media__ph::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid currentColor;
  opacity: .28;
}
.media__ph-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  max-width: 30ch;
  padding: 8px;
  text-align: center;
}
.ph-tag {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  opacity: .6;
}
.ph-name {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 5vw, 1.9rem);
  line-height: 1.05;
}
.ph-file {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .01em;
  padding: 4px 8px;
  border: 1px solid currentColor;
  opacity: .85;
}
.ph-note {
  font-size: 11.5px;
  line-height: 1.5;
  opacity: .62;
  max-width: 26ch;
}

/* compact variant for small crops */
.media[data-ph-pos="top"] .media__ph { align-items: start; padding-top: clamp(46px, 14vh, 120px); }
.media[data-ph-pos="bottom"] .media__ph { align-items: end; padding-bottom: clamp(46px, 14vh, 120px); }

.media[data-ph-size="sm"] .media__ph::before { inset: 8px; }
.media[data-ph-size="sm"] .media__ph-inner { gap: 6px; }
.media[data-ph-size="sm"] .ph-name { font-size: 1rem; }
.media[data-ph-size="sm"] .ph-file { font-size: 9px; padding: 3px 5px; }
.media[data-ph-size="sm"] .ph-tag  { font-size: 8px; }
.media[data-ph-size="sm"] .ph-note { display: none; }

/* Placeholder tones — keeps the composition reading correctly while photos are missing. */
.media[data-tone="dusk"]   { --ph-bg: #2C3742; }
.media[data-tone="stone"]  { --ph-bg: #6E6459; }
.media[data-tone="sea"]    { --ph-bg: #27515A; }
.media[data-tone="ember"]  { --ph-bg: #713424; }
.media[data-tone="clay"]   { --ph-bg: #9A5138; }
.media[data-tone="garnet"] { --ph-bg: #3E2233; }
.media[data-tone="gold"]   { --ph-bg: #8A6238; }
.media[data-tone="paper"]  { --ph-bg: #DED5C6; --ph-ink: rgba(20, 18, 15, .82); }
.media[data-tone="paper"] .media__ph {
  background: repeating-linear-gradient(45deg, rgba(20,18,15,.05) 0 1px, transparent 1px 9px);
}

/* Scrims — only where type sits over photography. */
.scrim { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.scrim--bottom {
  background: linear-gradient(to top,
    rgba(12, 10, 9, .74) 0%, rgba(12, 10, 9, .34) 30%, rgba(12, 10, 9, 0) 62%);
}
.scrim--updown {
  background:
    linear-gradient(to bottom, rgba(12, 10, 9, .58) 0%, rgba(12, 10, 9, 0) 42%),
    linear-gradient(to top,    rgba(12, 10, 9, .70) 0%, rgba(12, 10, 9, 0) 52%);
}
/* Seats the closing line on a bright sky without flattening the whole photo. */
.scrim--soft {
  background:
    linear-gradient(to bottom,
      rgba(12, 10, 9, 0) 18%,
      rgba(12, 10, 9, .50) 40%,
      rgba(12, 10, 9, .50) 58%,
      rgba(12, 10, 9, 0) 82%),
    rgba(12, 10, 9, .18);
}

/* ── 5. Type ───────────────────────────────────────────────── */
.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--t-display);
  line-height: .92;
  letter-spacing: -.02em;
}
.display--sm  { font-size: var(--t-title); }
.display--end { font-size: clamp(2.9rem, 14vw, 6.4rem); line-height: .96; }

.statement {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--t-state);
  line-height: 1.08;
  letter-spacing: -.012em;
  max-width: 20ch;
  text-wrap: balance;
}

.line {
  font-family: var(--serif);
  font-size: var(--t-line);
  line-height: 1.12;
  letter-spacing: -.01em;
}

.lede {
  margin-top: .85rem;
  font-size: var(--t-body);
  letter-spacing: .01em;
  color: var(--fg-mute);
}

.eyebrow, .tags li, .row__key, .ph-tag {
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
}

.meta {
  font-size: var(--t-small);
  line-height: 1.7;
  letter-spacing: .04em;
  color: var(--fg-mute);
}

/* ── 6. Slides ─────────────────────────────────────────────── */

/* 01 — opening */
.slide--hero .display { max-width: 12ch; }

/* 02 — premise */
.slide--premise .line { margin-top: .45rem; }
.slide--premise .meta { margin-top: 1.5rem; }
.but {
  margin-top: clamp(2.4rem, 9vh, 4.5rem);
  font-family: var(--serif);
  font-size: var(--t-line);
  color: var(--accent);
}

/* 03 — the city */
.city__foot { display: flex; align-items: flex-end; gap: clamp(16px, 4vw, 32px); }
.media--inset {
  flex: 0 0 auto;
  width: min(46%, 260px);
  aspect-ratio: 3 / 4;
}
.tags {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding-bottom: .2rem;
  color: var(--fg-mute);
}
.tags li { position: relative; padding-left: 1.15rem; }
.tags li::before {
  content: "";
  position: absolute;
  left: 0; top: .52em;
  width: .65rem; height: 1px;
  background: currentColor;
  opacity: .75;
}

/* 04 — the plan */
.split { display: flex; flex-direction: column; height: 100%; }
.split__media { position: relative; flex: 0 0 36%; min-height: 0; }
.split__body  { position: relative; flex: 1 1 auto; min-height: 0; background: var(--cream); }

.eyebrow { color: var(--fg-mute); }
.rows { margin-top: clamp(1.3rem, 4vw, 2rem); }
.row {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: clamp(.8rem, 2.6vw, 1.15rem) 0;
  border-top: 1px solid var(--rule);
}
.row:last-child { border-bottom: 1px solid var(--rule); }
.row__key { color: var(--fg-mute); }
.row__val {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 5.6vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -.01em;
}

/* 05 — on brand */
/* 05 — the collage. One feature tile plus four; the shape flips at the
   breakpoint, so every photo is supplied square and cropped by object-fit. */
.collage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  height: min(72vh, 620px);
}
.collage__cell { min-width: 0; min-height: 0; }
.collage__cell:nth-child(1) { grid-column: 1 / -1; }

.collage__label {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 26px 10px 10px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--on-dark);
  text-shadow: 0 1px 2px rgba(12, 10, 9, .75);
  background: linear-gradient(to top,
    rgba(12, 10, 9, .92) 0%,
    rgba(12, 10, 9, .74) 34%,
    rgba(12, 10, 9, .32) 66%,
    rgba(12, 10, 9, 0) 100%);
}

/* 06 — us */
.slide--us .frame { align-items: flex-start; }
.also {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 6vw, 2.1rem);
  color: var(--fg-mute);
}
.media--portrait {
  width: 100%;
  max-width: 460px;
  aspect-ratio: 4 / 5;
  max-height: 54vh;
  margin: clamp(1.1rem, 3.5vh, 2rem) 0;
}
.line--after { max-width: 16ch; }

/* 07 — ending, 08 — the beads */
.lede--end {
  margin-top: 1.1rem;
  font-size: var(--t-label);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--on-dark);
}

.nudge {
  margin-top: clamp(1.7rem, 5.5vh, 2.8rem);
  padding: 0 0 5px;
  border: 0;
  border-bottom: 1px solid rgba(246, 241, 232, .45);
  background: none;
  color: var(--on-dark);
  font-family: var(--sans);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .85;
  cursor: pointer;
  transition: opacity .3s var(--ease), border-color .3s var(--ease);
}
.nudge:hover { opacity: 1; border-color: var(--accent); }
.nudge:focus-visible { outline: 1px solid var(--accent); outline-offset: 6px; }

/* 08 — the line, with the photo placed off to one side rather than
   filling the screen. Mobile stacks it; wider screens sit them side by side. */
.beads {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(1.5rem, 4.5vh, 2.4rem);
  width: 100%;
}
.beads__line { max-width: 12ch; }
.beads__photo {
  width: min(72%, 320px);
  aspect-ratio: 6 / 7;
  align-self: flex-end;
  /* it sits on top of another photo, so give it a little depth rather than
     a border - no frame, just separation */
  box-shadow: 0 18px 46px rgba(0, 0, 0, .45);
}
.scrim--deep { background: rgba(12, 10, 9, .58); }

/* ── 7. Chrome ─────────────────────────────────────────────── */
.progress {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  gap: 7px;
  transform: translateX(-50%);
}
.progress button {
  width: 18px; height: 16px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
}
.progress button::after {
  content: "";
  display: block;
  width: 100%; height: 1.5px;
  background: currentColor;
  opacity: .3;
  transition: opacity .45s var(--ease), background-color .45s var(--ease);
}
.progress button[aria-current="true"]::after { opacity: 1; background: var(--accent); }

.music {
  position: fixed;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: .55;
  transition: opacity .3s ease;
}
.music[hidden] { display: none; }
.music:hover, .music[aria-pressed="true"] { opacity: .95; }
.music__bars { display: flex; align-items: flex-end; gap: 3px; height: 16px; }
.music__bars i { width: 3px; height: 4px; background: currentColor; transition: height .3s ease; }
.music[aria-pressed="true"] .music__bars i { animation: eq .9s ease-in-out infinite alternate; }
.music[aria-pressed="true"] .music__bars i:nth-child(2) { animation-delay: .18s; }
.music[aria-pressed="true"] .music__bars i:nth-child(3) { animation-delay: .36s; }
@keyframes eq { from { height: 4px; } to { height: 16px; } }

/* chrome adapts to the active slide's theme */
body[data-theme="dark"]  .progress, body[data-theme="dark"]  .music { color: var(--on-dark); }
body[data-theme="light"] .progress, body[data-theme="light"] .music { color: var(--ink); }
.progress, .music { transition: color .5s var(--ease); }

/* first-slide nudge, retired after the first move */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(58px + env(safe-area-inset-bottom));
  z-index: 3;
  transform: translateX(-50%);
  transition: opacity .5s ease;
}
.hint__rule {
  display: block;
  width: 34px; height: 1px;
  background: rgba(246, 241, 232, .8);
  animation: nudge 2.6s var(--ease) infinite;
}
@keyframes nudge {
  0%, 100% { opacity: 0; transform: translateY(-5px); }
  35%, 55% { opacity: .85; transform: translateY(0); }
}
.hint.is-gone { opacity: 0; }

/* ── 8. Breakpoints ────────────────────────────────────────── */
.br-lg { display: none; }

@media (min-width: 720px) {
  .statement { max-width: 24ch; }

  /* 04 — image beside the plan rather than above it */
  .split { flex-direction: row; }
  .split__media { flex: 0 0 46%; }
  .split__body  { flex: 1 1 auto; }
  .split__body .frame { max-width: 620px; margin: 0; }

  /* 03 */
  .city__foot { align-items: flex-end; gap: 40px; }
  .media--inset { width: 240px; }

  /* 05 — the feature tile turns tall and moves to the left */
  .collage {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    height: min(62vh, 520px);
    max-width: 980px;
    margin: 0 auto;
  }
  .collage__cell:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
  .collage__label { font-size: 11px; padding: 30px 13px 12px; }

  /* 08 */
  .beads {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(40px, 6vw, 84px);
  }
  .beads__line { max-width: 10ch; }
  .beads__photo { width: min(38%, 330px); align-self: auto; }

  /* 06 */
  .slide--us .frame { align-items: center; text-align: center; }
  .line--after { max-width: none; }
  .media--portrait { max-height: 52vh; }
}

@media (min-width: 900px) {
  .br-lg { display: inline; }
  .slide--city .statement { max-width: none; }
}

@media (min-width: 1080px) {
  .slide--hero .display { letter-spacing: -.03em; }
  .media--inset { width: 280px; }
  /* room for the labels to sit on one line beside the crop */
  .tags { flex-direction: row; flex-wrap: wrap; gap: .6rem 1.5rem; }
}

/* Short viewports (a phone turned sideways): tighten the whole system. */
@media (max-height: 560px) {
  :root {
    --pad-y:     18px;
    --chrome:    30px;
    --t-display: clamp(2.4rem, 11vh, 4.6rem);
    --t-title:   clamp(1.9rem, 8.5vh, 3rem);
    --t-state:   clamp(1.4rem, 6vh, 2.1rem);
    --t-line:    clamp(1.15rem, 5vh, 1.7rem);
  }
  .lede { margin-top: .5rem; }
  .but  { margin-top: 1.5rem; }
  .also { font-size: 1.2rem; }
  .rows { margin-top: .8rem; }
  .row { padding: .45rem 0; }
  .row__val { font-size: clamp(1.05rem, 4.6vh, 1.45rem); }
  .media--portrait { max-height: 46vh; margin: .6rem 0; }
  .media--inset { width: 150px; }
}

/* Small phones in portrait: the plan list is the tallest block in the deck,
   so give it back the room the ticks and music control take. */
@media (max-height: 640px) and (max-width: 719px) {
  .rows { margin-top: .9rem; }
  .row { padding: .5rem 0; }
  .row__val { font-size: clamp(1.1rem, 4.6vw, 1.5rem); }
}

/* Very short viewports: the plan list needs the last of the room back. */
@media (max-height: 420px) {
  :root { --pad-y: 14px; --chrome: 26px; }
  .rows { margin-top: .5rem; }
  .row { padding: .3rem 0; }
  .row__val { font-size: 1.05rem; }
  .row__key, .eyebrow { font-size: .625rem; }
}

/* Landscape: slide 04 goes side-by-side, and the collage keeps its wide shape. */
@media (max-height: 560px) and (min-width: 500px) {
  .split { flex-direction: row; }
  .split__media { flex: 0 0 40%; }
  .split__body  { flex: 1 1 auto; }
  .split__body .frame { max-width: 560px; margin: 0; }

  .collage {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    height: min(76vh, 300px);
    max-width: 660px;
    margin: 0 auto;
    gap: 6px;
  }
  .collage__cell:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
  .collage__label { font-size: 9px; padding: 20px 8px 8px; letter-spacing: .1em; }
}

/* ── Motion preferences ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  :root { --fade: 240ms; }
  .slide.is-active .media.has-image .media__img { animation: none; }
  [data-reveal] { transform: none !important; transition-delay: 0ms !important; transition-duration: .3s !important; }
  .hint__rule, .music[aria-pressed="true"] .music__bars i { animation: none; }
}
