:root {
  --ink: #15110f;
  --ink-soft: #3a322d;
  --paper: #fbf7f4;
  --cloud: #f3ece6;
  --nude: #e7d4c4;
  --nude-deep: #d8bfa9;
  --peony: #d8456b;
  --peony-deep: #b8345a;
  --blush: #f6d3dc;
  --muted: #8a7d75;
  --line: rgba(21, 17, 15, 0.12);
  --panel: rgba(251, 247, 244, 0.72);
  --shadow: 0 24px 70px rgba(21, 17, 15, 0.16);
  --error: #b5524a;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "Archivo", Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

body.is-loading {
  overflow: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    radial-gradient(
      120% 80% at 50% -10%,
      rgba(216, 69, 107, 0.07) 0%,
      rgba(216, 69, 107, 0) 60%
    ),
    linear-gradient(180deg, var(--paper) 0%, var(--cloud) 100%);
}

body::after {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: 38vh;
  content: "";
  background:
    linear-gradient(180deg, rgba(243, 236, 230, 0), rgba(231, 212, 196, 0.5)),
    linear-gradient(90deg, rgba(216, 69, 107, 0.06), rgba(21, 17, 15, 0.04));
}

a {
  color: inherit;
}

/* ---------- Intro / swatch swipe ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--ink);
  pointer-events: none;
  transform: translateY(0);
  will-change: transform;
}

.intro-stage {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.intro-eyebrow {
  margin: 0;
  color: rgba(251, 247, 244, 0.62);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0;
  animation: intro-fade 620ms ease 120ms forwards;
}

.intro-wordmark {
  position: relative;
  display: inline-block;
  padding: 4px 2px 12px;
}

.intro-mark {
  display: block;
  color: var(--paper);
  line-height: 0;
  opacity: 0;
  animation: intro-rise 720ms cubic-bezier(0.2, 0.7, 0.2, 1) 200ms forwards;
}

.intro-mark .logo-img {
  display: block;
  width: min(64vw, 290px);
  height: auto;
  /* Official logo is black on transparent; flip to white on the ink intro. */
  filter: invert(1);
}

.intro-swatch {
  position: absolute;
  bottom: 0;
  left: -2%;
  width: 104%;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--peony), var(--peony-deep));
  transform: scaleX(0);
  transform-origin: left center;
  filter: drop-shadow(0 6px 14px rgba(216, 69, 107, 0.45));
  animation: swatch-swipe 760ms cubic-bezier(0.65, 0, 0.2, 1) 560ms forwards;
}

.intro-tagline {
  margin: 0;
  color: var(--blush);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  opacity: 0;
  animation: intro-fade 640ms ease 980ms forwards;
}

body.is-ready .intro {
  transform: translateY(-101%);
  transition: transform 720ms cubic-bezier(0.76, 0, 0.24, 1);
}

html.has-viewed-brochure .intro {
  display: none;
}

/* ---------- Shell + hero ---------- */
.shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(46px, env(safe-area-inset-top)) 18px
    max(34px, env(safe-area-inset-bottom));
}

.hero {
  padding: 6px 4px 26px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--peony-deep);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.brand {
  margin: 14px 0 0;
  color: var(--ink);
  line-height: 0;
}

.brand .logo-img {
  display: block;
  width: min(74%, 320px);
  height: auto;
  margin: 0 auto;
}

.swipe-line {
  position: relative;
  width: 84px;
  height: 7px;
  margin: 20px auto 22px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--peony), var(--peony-deep));
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
}

.hero-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.5;
}

/* ---------- Language panel ---------- */
.language-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(21, 17, 15, 0.06);
  backdrop-filter: blur(6px);
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.language-card {
  position: relative;
  display: grid;
  align-items: center;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  min-height: 78px;
  padding: 14px 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(251, 247, 244, 0.96),
    rgba(243, 236, 230, 0.82)
  );
  box-shadow: 0 10px 26px rgba(21, 17, 15, 0.06);
  text-decoration: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease,
    background 150ms ease;
  animation: card-in 420ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--stagger-index, 0) * 24ms);
}

.language-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  content: "";
  background: var(--peony);
  opacity: 0;
  transition: opacity 150ms ease;
}

.language-card:focus-visible,
.language-card:hover {
  border-color: rgba(216, 69, 107, 0.6);
  background: linear-gradient(
    135deg,
    rgba(251, 247, 244, 1),
    rgba(246, 211, 220, 0.6)
  );
  box-shadow: 0 16px 34px rgba(216, 69, 107, 0.16);
  outline: none;
  transform: translateY(-1px);
}

.language-card:focus-visible::before,
.language-card:hover::before {
  opacity: 1;
}

.language-card.is-detected {
  border-color: rgba(216, 69, 107, 0.55);
  box-shadow: 0 12px 30px rgba(216, 69, 107, 0.16);
}

.language-card.is-detected::before {
  opacity: 1;
}

.language-flag {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(21, 17, 15, 0.12);
  border-radius: 50%;
  background: var(--paper);
  box-shadow:
    inset 0 0 0 2px rgba(251, 247, 244, 0.72),
    0 8px 18px rgba(21, 17, 15, 0.08);
}

.language-flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.language-text {
  display: block;
  min-width: 0;
}

.detected-badge {
  position: absolute;
  top: 9px;
  right: 10px;
  color: var(--peony-deep);
  font-size: 0.56rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[dir="rtl"] .detected-badge {
  right: auto;
  left: 10px;
}

.language-native {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: clamp(0.98rem, 4vw, 1.08rem);
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.language-english {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Legacy viewer header (kept for compatibility) ---------- */
.viewer-shell {
  display: grid;
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.viewer-header {
  display: grid;
  align-items: center;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(251, 247, 244, 0.84);
  box-shadow: 0 14px 40px rgba(21, 17, 15, 0.1);
  backdrop-filter: blur(18px);
}

.viewer-header h1 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.icon-link {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
}

.icon-link:focus-visible,
.icon-link:hover {
  border-color: rgba(216, 69, 107, 0.8);
  outline: none;
}

.icon-link[aria-disabled="true"] {
  opacity: 0.42;
  pointer-events: none;
}

/* ---------- PDF viewer ---------- */
body[data-page="viewer"] {
  min-height: 100vh;
  background: #ece6e0;
}

body[data-page="viewer"]::before,
body[data-page="viewer"]::after {
  display: none;
}

.pdf-viewer-shell {
  min-height: 100vh;
  background: #ece6e0;
}

.pdf-viewer-toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid rgba(21, 17, 15, 0.12);
  background: rgba(251, 247, 244, 0.94);
  box-shadow: 0 1px 10px rgba(21, 17, 15, 0.08);
  backdrop-filter: blur(12px);
}

.pdf-viewer-back,
.pdf-viewer-original {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid rgba(21, 17, 15, 0.18);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.pdf-viewer-back svg {
  flex: 0 0 auto;
}

.pdf-viewer-original {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  background: var(--ink);
  color: var(--paper);
}

.pdf-viewer-back:focus-visible,
.pdf-viewer-original:focus-visible {
  outline: 2px solid rgba(216, 69, 107, 0.5);
  outline-offset: -2px;
}

.pdf-viewer-pages {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: 100%;
  overflow-x: auto;
  padding: 10px 0 24px;
  overscroll-behavior-x: contain;
}

.pdf-viewer-pages--fallback {
  overflow-x: hidden;
  padding: 16px 12px 24px;
}

.pdf-viewer-fallback {
  display: grid;
  gap: 12px;
  width: min(100%, 980px);
  min-height: calc(100vh - 92px);
}

.pdf-viewer-fallback-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.pdf-viewer-fallback-link {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
}

.pdf-viewer-fallback-link:focus-visible {
  outline: 2px solid rgba(216, 69, 107, 0.5);
  outline-offset: 2px;
}

.pdf-viewer-fallback-frame {
  width: 100%;
  min-height: calc(100vh - 180px);
  border: 1px solid rgba(21, 17, 15, 0.12);
  border-radius: 9px;
  background: var(--paper);
}

.pdf-viewer-page {
  position: relative;
  display: grid;
  width: max-content;
  min-width: 100%;
  justify-items: center;
}

.pdf-viewer-page canvas {
  display: block;
  height: auto;
  background: var(--paper);
  box-shadow: 0 1px 8px rgba(21, 17, 15, 0.18);
}

/* ---------- Status + keyframes ---------- */
.pdf-status {
  display: grid;
  min-height: 620px;
  align-content: center;
  justify-items: center;
  gap: 10px;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.pdf-status[hidden] {
  display: none;
}

.pdf-status p {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.pdf-status span {
  min-height: 1.1em;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.pdf-status-graphic {
  width: 42px;
  height: 42px;
  margin-bottom: 8px;
  border-radius: 50%;
}

.pdf-status-graphic.is-loading,
.pdf-status-graphic.is-slow {
  border: 2px solid rgba(216, 69, 107, 0.22);
  border-top-color: var(--peony);
  animation: spin 900ms linear infinite;
}

.pdf-status-graphic.is-slow {
  border-top-color: var(--ink-soft);
  animation-duration: 1300ms;
}

.retry-button {
  min-width: 128px;
  margin-top: 8px;
  padding: 11px 18px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
}

.retry-button:focus-visible,
.retry-button:hover {
  border-color: var(--peony);
  outline: none;
}

@keyframes intro-fade {
  to {
    opacity: 1;
  }
}

@keyframes intro-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes swatch-swipe {
  0% {
    transform: scaleX(0);
    transform-origin: left center;
  }

  60% {
    transform: scaleX(1);
    transform-origin: left center;
  }

  60.01% {
    transform-origin: right center;
  }

  100% {
    transform: scaleX(1);
    transform-origin: right center;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 430px) {
  .shell {
    padding: 32px 12px 24px;
  }

  .hero {
    padding-bottom: 20px;
  }

  .language-panel {
    padding: 10px;
  }

  .language-grid {
    gap: 8px;
  }

  .language-card {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    min-height: 74px;
    padding: 12px 10px;
  }

  .language-flag {
    width: 34px;
    height: 34px;
  }

  .pdf-viewer-back,
  .pdf-viewer-original {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .pdf-viewer-back {
    width: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro {
    display: none;
  }

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