@layer reset, base, components, states;

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

  html {
    scroll-behavior: smooth;
  }

  body,
  h1,
  h2,
  p {
    margin: 0;
  }

  button,
  a {
    font: inherit;
  }
}

@layer base {
  :root {
    color-scheme: dark;
    --ink: #fff8e9;
    --ink-muted: rgba(255, 248, 233, 0.72);
    --deep-sea: #061b25;
    --sea: #0c5265;
    --sun: #ffd28a;
    --progress: 0;
    --intro-opacity: 1;
    --kicker-opacity: 0;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
  }

  body {
    min-width: 320px;
    overflow-x: clip;
    color: var(--ink);
    background: var(--deep-sea);
  }

  a {
    color: inherit;
  }

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

  :focus-visible {
    outline: 2px solid var(--sun);
    outline-offset: 5px;
  }

  .skip-link {
    position: fixed;
    z-index: 100;
    top: 1rem;
    left: 1rem;
    padding: 0.75rem 1rem;
    color: #082632;
    background: var(--ink);
    border-radius: 999px;
    transform: translateY(-160%);
    transition: transform 180ms ease;
  }

  .skip-link:focus {
    transform: translateY(0);
  }
}

@layer components {
  .scroll-story {
    position: relative;
    height: 700svh;
  }

  .stage {
    position: sticky;
    top: 0;
    height: 100svh;
    min-height: 35rem;
    overflow: hidden;
    isolation: isolate;
    background: var(--deep-sea);
  }

  .film-shell,
  .film-ambient,
  .film-shade {
    position: absolute;
    inset: 0;
  }

  .film-shell {
    z-index: -1;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
      radial-gradient(circle at 50% 35%, rgba(33, 112, 139, 0.35), transparent 46%),
      #061b25;
  }

  .film-ambient {
    inset: -4rem;
    background: url("assets/poster-start.jpg") center / cover no-repeat;
    filter: blur(34px) saturate(0.8) brightness(0.5);
    opacity: 0.52;
    transform: scale(1.06);
    transition: opacity 700ms ease;
  }

  .film {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    filter: saturate(1.02) contrast(1.015);
    transition: opacity 650ms ease;
  }

  .film-shade {
    pointer-events: none;
    background:
      linear-gradient(180deg, rgba(3, 16, 23, 0.52) 0%, transparent 20%, transparent 66%, rgba(3, 16, 23, 0.36) 100%),
      linear-gradient(90deg, rgba(3, 16, 23, 0.18), transparent 38%, transparent 75%, rgba(3, 16, 23, 0.1));
    transition: background 600ms ease;
  }

  .site-header {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 0;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding:
      max(1.5rem, env(safe-area-inset-top))
      clamp(1.25rem, 4.2vw, 5rem)
      1rem;
    text-shadow: 0 2px 22px rgba(1, 16, 24, 0.5);
  }

  .brand {
    display: inline-flex;
    align-items: baseline;
    color: var(--ink);
    font-size: clamp(1.05rem, 1.45vw, 1.5rem);
    font-weight: 720;
    letter-spacing: -0.045em;
    text-decoration: none;
  }

  .brand i {
    width: 0.26em;
    height: 0.26em;
    margin: 0 0.12em 0.07em;
    overflow: hidden;
    color: transparent;
    background: var(--sun);
    border-radius: 50%;
    box-shadow: 0 0 0 0.3rem rgba(255, 210, 138, 0.14);
  }

  .brand-note {
    display: inline-flex;
    gap: 0.55rem;
    align-items: center;
    color: var(--ink-muted);
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.16em;
    text-decoration: none;
    text-transform: uppercase;
  }

  .catalog-link {
    padding: 0.55rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    backdrop-filter: blur(12px);
    transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
  }

  .catalog-link svg {
    width: 0.9rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
    transition: transform 180ms ease;
  }

  .catalog-link:hover {
    color: var(--ink);
    background: rgba(6, 34, 45, 0.32);
    border-color: rgba(255, 255, 255, 0.34);
  }

  .catalog-link:hover svg {
    transform: translateX(0.15rem);
  }

  .loader {
    position: absolute;
    z-index: 9;
    top: 50%;
    left: 50%;
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 0.8rem;
    row-gap: 0.35rem;
    align-items: center;
    min-width: 13rem;
    padding: 1rem 1.15rem;
    background: rgba(3, 24, 34, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 1.1rem;
    box-shadow: 0 1.2rem 3rem rgba(0, 13, 20, 0.28);
    backdrop-filter: blur(18px);
    transform: translate(-50%, -50%);
    transition: opacity 350ms ease, visibility 350ms ease;
  }

  .loader__mark {
    grid-row: 1 / 3;
    width: 1.8rem;
    height: 1.8rem;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--sun);
    border-radius: 50%;
    animation: spin 850ms linear infinite;
  }

  .loader__label,
  .loader__value {
    line-height: 1;
  }

  .loader__label {
    font-size: 0.82rem;
    font-weight: 650;
  }

  .loader__value {
    color: var(--ink-muted);
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  .intro {
    position: absolute;
    z-index: 2;
    left: clamp(1.25rem, 7vw, 8.5rem);
    bottom: clamp(7rem, 14vh, 10rem);
    max-width: 62rem;
    opacity: var(--intro-opacity);
    transform: translate3d(0, calc(var(--progress) * -2rem), 0);
    pointer-events: none;
    will-change: opacity, transform;
  }

  .eyebrow {
    margin-bottom: 0.8rem;
    color: var(--sun);
    font-size: clamp(0.68rem, 0.9vw, 0.82rem);
    font-weight: 760;
    letter-spacing: 0.19em;
    text-transform: uppercase;
  }

  .intro h1,
  .final-panel h2 {
    font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
    font-weight: 400;
    letter-spacing: -0.055em;
    line-height: 0.91;
    text-wrap: balance;
  }

  .intro h1 {
    max-width: 12ch;
    font-size: clamp(3.2rem, 7.2vw, 8.8rem);
    text-shadow: 0 4px 34px rgba(0, 19, 30, 0.4);
  }

  .story-kicker {
    position: absolute;
    z-index: 3;
    left: clamp(1.25rem, 4.2vw, 5rem);
    bottom: max(2.1rem, env(safe-area-inset-bottom));
    padding: 0.58rem 0.8rem;
    color: rgba(255, 255, 255, 0.82);
    background: rgba(3, 24, 34, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 680;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: var(--kicker-opacity);
    backdrop-filter: blur(12px);
    transition: opacity 220ms ease, transform 220ms ease;
  }

  .final-panel {
    position: absolute;
    z-index: 4;
    left: clamp(1.25rem, 7vw, 8.5rem);
    bottom: max(3rem, calc(env(safe-area-inset-bottom) + 2rem));
    width: min(31rem, calc(100vw - 2.5rem));
    padding: clamp(1.35rem, 2.2vw, 2rem);
    background: linear-gradient(145deg, rgba(5, 40, 51, 0.78), rgba(7, 58, 69, 0.48));
    border: 1px solid rgba(224, 247, 244, 0.2);
    border-radius: 1.65rem;
    box-shadow: 0 1.8rem 5rem rgba(0, 17, 23, 0.35);
    opacity: 0;
    visibility: hidden;
    backdrop-filter: blur(20px) saturate(1.15);
    transform: translate3d(0, 1.8rem, 0) scale(0.98);
    transition:
      opacity 620ms cubic-bezier(0.2, 0.8, 0.2, 1),
      transform 620ms cubic-bezier(0.2, 0.8, 0.2, 1),
      visibility 620ms;
  }

  .final-panel h2 {
    margin-bottom: 1rem;
    font-size: clamp(2.65rem, 4.5vw, 5.2rem);
  }

  .final-panel__copy {
    max-width: 34ch;
    margin-bottom: 1.4rem;
    color: rgba(239, 251, 247, 0.76);
    font-size: clamp(0.9rem, 1.2vw, 1.02rem);
    line-height: 1.55;
  }

  .order-button {
    display: inline-flex;
    gap: 1.4rem;
    align-items: center;
    justify-content: space-between;
    min-width: min(100%, 17.5rem);
    padding: 0.95rem 1.05rem 0.95rem 1.2rem;
    color: #0b3340;
    background: var(--ink);
    border-radius: 999px;
    box-shadow: 0 0.8rem 2rem rgba(1, 18, 23, 0.2);
    font-size: 0.82rem;
    font-weight: 760;
    text-decoration: none;
    transition: color 180ms ease, background 180ms ease, transform 180ms ease;
  }

  .order-button svg {
    width: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
    transition: transform 180ms ease;
  }

  .order-button:hover {
    color: #092a35;
    background: var(--sun);
    transform: translateY(-2px);
  }

  .order-button:hover svg {
    transform: translateX(0.2rem);
  }

  .scroll-cue {
    position: absolute;
    z-index: 5;
    right: clamp(1.25rem, 4.2vw, 5rem);
    bottom: max(1.8rem, env(safe-area-inset-bottom));
    display: inline-flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0;
    color: rgba(255, 255, 255, 0.78);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 0.67rem;
    font-weight: 680;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    transition: opacity 320ms ease, transform 320ms ease;
  }

  .scroll-cue svg {
    width: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
    animation: dive 1.6s ease-in-out infinite;
  }

  @keyframes dive {
    0%, 100% { transform: translateY(-0.14rem); }
    50% { transform: translateY(0.25rem); }
  }

  .timeline {
    position: absolute;
    z-index: 4;
    top: 50%;
    right: clamp(1rem, 2vw, 2.4rem);
    display: grid;
    gap: 0.55rem;
    justify-items: center;
    transform: translateY(-50%);
  }

  .timeline__number {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.58rem;
    font-variant-numeric: tabular-nums;
    font-weight: 720;
    letter-spacing: 0.08em;
  }

  .timeline__track {
    position: relative;
    width: 1px;
    height: clamp(6rem, 18vh, 10rem);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.24);
  }

  .timeline__fill {
    position: absolute;
    inset: 0;
    background: var(--sun);
    transform: scaleY(var(--progress));
    transform-origin: top;
    will-change: transform;
  }

  .noscript-card {
    position: absolute;
    z-index: 20;
    inset: auto 1.5rem 1.5rem;
    padding: 1rem;
    background: #0b3c4b;
    border-radius: 1rem;
  }

  .noscript-card a {
    display: inline-block;
    margin-top: 0.6rem;
    color: var(--sun);
  }
}

@layer states {
  body.is-ready .film {
    opacity: 1;
  }

  body.is-ready .loader {
    opacity: 0;
    visibility: hidden;
  }

  body.has-scrolled .scroll-cue {
    opacity: 0;
    pointer-events: none;
    transform: translateY(0.6rem);
  }

  body.is-complete .final-panel {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0) scale(1);
  }

  body.is-complete .story-kicker,
  body.is-complete .scroll-cue {
    opacity: 0;
    pointer-events: none;
  }

  body.is-complete .film-shade {
    background:
      linear-gradient(180deg, rgba(3, 18, 24, 0.18), transparent 30%, rgba(0, 26, 33, 0.08) 52%, rgba(0, 27, 35, 0.48) 100%),
      linear-gradient(90deg, rgba(0, 27, 35, 0.24), transparent 65%);
  }

  body.is-complete .film-ambient {
    background-image: url("assets/poster-end.jpg");
  }

  @media (max-width: 720px) {
    .scroll-story {
      height: 580svh;
    }

    .stage {
      min-height: 31rem;
    }

    .film-shell {
      align-items: center;
    }

    .film {
      top: 50%;
      bottom: auto;
      height: auto;
      min-height: 0;
      aspect-ratio: 2206 / 946;
      transform: translateY(-50%);
    }

    .film-ambient {
      opacity: 0.42;
      filter: blur(26px) saturate(0.84) brightness(0.42);
    }

    .site-header {
      padding-inline: 1.15rem;
    }

    .timeline {
      display: none;
    }

    .catalog-link span {
      display: none;
    }

    .catalog-link {
      padding: 0.58rem;
    }

    .intro {
      left: 1.25rem;
      bottom: max(5.8rem, calc(env(safe-area-inset-bottom) + 5rem));
    }

    .intro h1 {
      font-size: clamp(3.05rem, 15vw, 5.2rem);
    }

    .story-kicker {
      left: 1.15rem;
      bottom: max(1.25rem, env(safe-area-inset-bottom));
    }

    .scroll-cue {
      right: 1.15rem;
      bottom: max(1.4rem, env(safe-area-inset-bottom));
    }

    .scroll-cue span {
      display: none;
    }

    .final-panel {
      left: 1rem;
      bottom: max(1rem, env(safe-area-inset-bottom));
      width: calc(100vw - 2rem);
      padding: 1.25rem;
      border-radius: 1.35rem;
    }

    .final-panel h2 {
      font-size: clamp(2.55rem, 12vw, 4rem);
    }

    .final-panel__copy {
      margin-bottom: 1.1rem;
      font-size: 0.88rem;
    }

    .order-button {
      width: 100%;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      scroll-behavior: auto !important;
    }

    body.is-reduced-motion .scroll-story {
      height: 100svh;
    }

    body.is-reduced-motion .film-ambient,
    body.is-reduced-motion .film {
      background-image: url("assets/poster-end.jpg");
    }

    body.is-reduced-motion .film {
      opacity: 0;
    }

    body.is-reduced-motion .film-ambient {
      inset: 0;
      opacity: 1;
      filter: none;
      transform: none;
    }

    body.is-reduced-motion .intro,
    body.is-reduced-motion .story-kicker,
    body.is-reduced-motion .timeline,
    body.is-reduced-motion .scroll-cue,
    body.is-reduced-motion .loader {
      display: none;
    }
  }
}
