/* Scalar Core v2: editorial motion + display type scale.
   Loaded last on every page. Fonts, copy, colours and photography are the
   originals; this layer only changes scale, rhythm and movement.          */

:root {
  --v2-ease: cubic-bezier(.16, 1, .3, 1);
  --v2-ease-io: cubic-bezier(.76, 0, .24, 1);
}

::selection { background: var(--accent); color: var(--accent-ink, #121510); }
html.v2-smooth { scroll-behavior: auto !important; }

/* ------------------------------------------------------------ type scale */
html[data-motion]:not(#v2):not(#v2) body#top#top :is(main h1, main h2, .desktop-object-copy h3, footer h2) {
  text-wrap: balance;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

@media (min-width: 1201px), (min-width: 1024px) and (orientation: landscape) {
  /* Section titles: one confident display size, clean leading. */
  html[data-motion]:not(#v2):not(#v2) body#top#top :is(#contents-title, #gameplay-title, #digital-title, #reviews-title, #craft-title, #heading-keycaps, .related-section h2) {
    font-size: clamp(34px, min(3.6vw, 4.85vh), 66px) !important;
    line-height: 1.08 !important;
    letter-spacing: -.025em !important;
  }
  /* Full-width statements go properly large. */
  html[data-motion]:not(#v2):not(#v2) body#top#top .makers-origin-title { font-size: clamp(40px, min(4.2vw, 5.6vh), 76px) !important; line-height: 1.08 !important; letter-spacing: -.025em !important; }
  html[data-motion]:not(#v2):not(#v2) body#top#top :is(#overview-title, #studio-gallery-title) {
    font-size: clamp(42px, min(5.1vw, 6.8vh), 92px) !important;
    line-height: 1.08 !important;
    letter-spacing: -.03em !important;
  }
  /* The four object studies read as chapter openers. */
  html[data-motion]:not(#v2):not(#v2) body#top#top .desktop-object-copy h3 {
    font-size: clamp(34px, min(3.5vw, 4.7vh), 64px) !important;
    line-height: 1.08 !important;
    letter-spacing: -.02em !important;
  }
  html[data-motion]:not(#v2):not(#v2) body#top#top .sc-footer-intro h2 {
    font-size: clamp(34px, min(3.3vw, 4.45vh), 60px) !important;
    line-height: 1.08 !important;
    letter-spacing: -.02em !important;
  }
  html[data-motion]:not(#v2):not(#v2) body#top#top #hero-section .campaign-intro {
    font-size: clamp(20px, min(2vw, 2.7vh), 34px) !important;
    line-height: 1.12 !important;
    letter-spacing: -.02em !important;
  }
  /* Eyebrows: wider tracking, the editorial label voice. */
  html[data-motion]:not(#v2):not(#v2) body#top#top main :is(.eyebrow, .campaign-kicker, .coming-kicker) { letter-spacing: .22em !important; }
}

@media (max-width: 1023px), (max-width: 1200px) and (orientation: portrait) {
  html[data-motion]:not(#v2):not(#v2) body#top#top :is(#overview-title, #studio-gallery-title, .makers-origin-title, #contents-title, #gameplay-title, #digital-title, #reviews-title, #edition-offer-title, #craft-title) {
    font-size: clamp(28px, 7.6vw, 52px) !important;
    line-height: 1.08 !important;
    letter-spacing: -.02em !important;
  }
  html[data-motion]:not(#v2):not(#v2) body#top#top .sc-footer-intro h2 { font-size: clamp(30px, 8vw, 48px) !important; line-height: 1.08 !important; }
}

/* --------------------------------------------------------- reveal states */
.v2-w { display: inline-block; overflow: hidden; vertical-align: top; line-height: 1 !important; padding: .12em .08em .18em; margin: -.12em -.08em -.18em; }
.v2-in .v2-w { overflow: visible !important; }
.v2-wi { display: inline-block; line-height: 1 !important; } /* no will-change: hundreds of words would each hold a layer */

html[data-motion]:not(#v2):not(#v2) body#top#top :is(.campaign-title, #coming-title, .dice-coming-wordmark) {
  line-height: 1.08 !important;
}
html[data-motion]:not(#v2):not(#v2) body#top#top :is(.campaign-title, #coming-title, .dice-coming-wordmark) > span {
  line-height: 1.02 !important;
}

@media (prefers-reduced-motion: no-preference) {
  /* Before the engine boots: hold the hero only, with a fail-safe release. */

  /* Before the engine boots, hold only the small hero items (never the large
     photo or copy, which must paint at once), with a fail-safe release. */
  html.v2-js:not(.v2-ready) :is(#hero-section, .coming-hero) :is(.campaign-kicker, .coming-kicker, .campaign-edition, .campaign-subtitle, .campaign-actions > *, .campaign-footer > *, .campaign-title > span) {
    opacity: 0; animation: v2-release 0s 2.4s forwards;
  }
  @keyframes v2-release { to { opacity: 1; } }
  html.v2-ready [data-v2r='rise']:not(.v2-in) { opacity: 0; }
  html.v2-ready [data-v2r='media']:not(.v2-in) { opacity: 0; }
  html.v2-ready [data-v2r='title']:not(.v2-in) > span { clip-path: inset(0 0 100% 0); }

  html.v2-ready [data-v2r='words'] .v2-wi {
    translate: 0 112%;
    rotate: 3.5deg;
    opacity: 0;
    transform-origin: 0 100%;
    transition:
      translate .85s var(--v2-ease) calc(var(--v2-delay, 0ms) + min(var(--i, 0), 14) * 36ms),
      rotate .85s var(--v2-ease) calc(var(--v2-delay, 0ms) + min(var(--i, 0), 14) * 36ms),
      opacity .45s ease calc(var(--v2-delay, 0ms) + min(var(--i, 0), 14) * 36ms);
  }
  html.v2-ready [data-v2r='words']:not(.v2-in) .v2-wi { translate: 0 112%; rotate: 3.5deg; opacity: 0; }
  html.v2-ready [data-v2r='words'].v2-in .v2-wi { translate: 0 0; rotate: 0deg; opacity: 1; }
}

/* ------------------------------------------------- curtain, photo fades */
.v2-wipe { position: absolute; z-index: 2; pointer-events: none; margin: 0; max-width: none; }

/* ------------------------------------------------------- rolling labels */
.v2-roll { position: relative; display: inline-block; overflow: hidden; vertical-align: top; }
.v2-roll > span { display: block; transition: translate .55s var(--v2-ease); }
.v2-roll > span + span { position: absolute; left: 0; top: 100%; color: var(--accent-ui, var(--accent)); opacity: 0; pointer-events: none; transition: translate .55s var(--v2-ease), opacity .2s ease; }
@media (hover: hover) and (pointer: fine) {
  a:hover > .v2-roll > span, a:focus-visible > .v2-roll > span { translate: 0 -100%; }
  a:hover > .v2-roll > span + span, a:focus-visible > .v2-roll > span + span { opacity: 1; }
}

/* -------------------------------------------------- desktop object stage */
@media (min-width: 901px) {
  html[data-motion]:not(#v2):not(#v2) body#top#top .desktop-object-copy {
    width: min(460px, calc(42vw - 32px)) !important;
    max-width: min(460px, calc(42vw - 32px)) !important;
  }
  html[data-motion]:not(#v2):not(#v2) body#top#top .desktop-object-visual {
    top: 100px !important;
    height: calc(100svh - 100px) !important;
    left: max(510px, 46vw) !important;
    right: clamp(24px, 4vw, 64px) !important;
    width: auto !important;
    max-width: min(880px, 50vw, calc((100svh - 100px) * 0.96)) !important;
  }
}

html[data-motion]:not(#v2):not(#v2) body#top#top .related-section .section-heading {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-end !important;
  justify-content: space-between !important;
  gap: 12px 32px !important;
}
html[data-motion]:not(#v2):not(#v2) body#top#top .related-section .section-heading > .eyebrow {
  flex: 1 1 100% !important;
}
html[data-motion]:not(#v2):not(#v2) body#top#top .related-section .section-heading > h2 {
  margin: 0 !important;
  flex: 0 1 auto !important;
}
html[data-motion]:not(#v2):not(#v2) body#top#top .related-section .section-heading > a {
  flex: 0 0 auto !important;
  margin-left: auto !important;
}

/* ----------------------------------------------------- pages */
@media (prefers-reduced-motion: no-preference) {
  /* Cross-page: the incoming page wipes up over the outgoing one, which
     sinks back. Both stay opaque, so the two pages never blend. */
  html[data-site-variant][data-motion]::view-transition-old(root) {
    animation: v2-page-out .24s var(--v2-ease-io) both !important;
    opacity: 1 !important;
  }
  html[data-site-variant][data-motion]::view-transition-new(root) {
    animation: v2-page-in .32s var(--v2-ease-io) both !important;
  }
  @keyframes v2-page-out { to { translate: 0 -8vh; scale: .97; filter: brightness(.45); } }
  @keyframes v2-page-in { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
}

/* ------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  .v2-wi { translate: none !important; rotate: none !important; }
  .v2-roll > span { transition: none; }
}
@media print {
  [data-v2r] { opacity: 1 !important; clip-path: none !important; }
  .v2-wi { translate: none !important; rotate: none !important; }
}

/* Audit fix: on landscape tablets (1024-1200px) the fixed chapter dock sat
   over the first letters of the hero and section copy. Hide it there only. */
@media (min-width: 1024px) and (max-width: 1200px) and (orientation: landscape) {
  html[data-motion]:not(#v2) body#top .chapter-dock { display: none !important; }
}

/* Tablet side-by-side object study: centre the image against its copy card. */
@media (min-width: 700px) and (max-width: 1200px) and (orientation: portrait) {
  html[data-motion]:not(#v2) body#top #object-dossier .dossier-visual { align-self: center; }
}

/* Big titles from the original site follow the screen's height too, so
   1920x1080 and 1440x900 keep the proportions of a tall screen. */
@media (min-width: 1201px), (min-width: 1024px) and (orientation: landscape) {
  html[data-motion]:not(#v2):not(#v2) body#top#top main .campaign-title { font-size: clamp(40px, min(4.02vw, 5.42vh), 96px) !important; }
  html[data-motion]:not(#v2):not(#v2) body#top#top:not([data-page=game]) main .campaign-intro { font-size: clamp(22px, 2.37vh, 30px) !important; }
  html[data-motion]:not(#v2):not(#v2) body#top#top .product-name { font-size: clamp(34px, min(3vw, 4.05vh), 64px) !important; }
}

/* Scroll performance: the fixed header and chapter dock no longer blur the
   page behind them (a full-width blur re-rasterises on every scrolled frame).
   A near-opaque fill reads the same. */
html[data-motion]:not(#v2):not(#v2) body#top#top :is(.site-header, .chapter-dock, .site-header .main-nav) {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html[data-motion]:not(#v2):not(#v2) body#top#top :is(.site-header, .chapter-dock) {
  background: color-mix(in srgb, var(--bg) 94%, transparent) !important;
}
