/* Owner-supplied EW artwork, approved warm ivory app text and one shared font.
   Keep these tokens separate so a later heading-font change stays small. */
@font-face {
  font-family: 'Lancelot';
  src: url('../../fonts/Lancelot-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

html { background-color: #00020a; }

/* Keep the document at the device width while retaining normal pinch zoom. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body.storybook {
  --navy: #01030a;
  --navy-soft: #020610;
  --brand-page-gradient: linear-gradient(135deg, #01030a 0%, #020610 50%, #00020a 100%);
  --brand-text-on-blue: var(--brand-heading-ink);
  --brand-heading-ink: #f5f2ec;
  --brand-accent-gold: #dfb87a;
  --cream: var(--brand-heading-ink);
  --muted: var(--brand-heading-ink);
  --gold: var(--brand-text-on-blue);
  --gold-soft: #fff0d6;
  --line: #dfb87a33;
  --font-display: 'Lancelot', Georgia, serif;
  --font-script: var(--font-display);
  --type-body: 18px;
  --type-quiet: 16px;
  --type-title: 36px;
  --type-subheading: 24px;
  color: var(--brand-text-on-blue);
  color-scheme: dark;
  background: var(--navy) var(--brand-page-gradient) center / cover no-repeat fixed;
}

body.storybook,
body.storybook * {
  font-weight: 400 !important;
  font-synthesis: none;
}

/* Copy stays unboxed, including headings focused after a screen change.
   Interactive controls keep their existing keyboard focus outlines. */
body.storybook :is(h1, h2, h3, [role='heading']) {
  outline: none !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
}

body.storybook :is(.support, .lede, .journey-tip, .journey-overview,
  .journey-external-card, .santa-frame-tip, .santa-chat-current) {
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
}

/* The same plain link and action treatment applies in every interaction state. */
body.storybook :is(a, button, summary, label.button),
body.storybook :is(a, button, summary, label.button) * {
  text-decoration: none !important;
}

body.storybook .home-santa-caption::after { display: none; }

/* Equal choice-card headings, including the featured journey. */
body.storybook[data-product='experiences'] :is(.experience, .experience-journey) h2 {
  font-size: var(--type-subheading) !important;
  line-height: 1.2;
}

/* The product name leads every introduction. Editorial lines are subordinate;
   later step headings use the same title size as the product name. */
body.storybook:is([data-product='reindeer'], [data-product='santa'],
  [data-product='tree-santa'], [data-product='santa-journey']) .product-heading {
  margin: 0 0 16px;
  color: var(--brand-text-on-blue);
  font-size: var(--type-title) !important;
  line-height: 1.12;
  text-wrap: balance;
}

body.storybook:is([data-product='reindeer'], [data-product='santa'],
  [data-product='tree-santa'], [data-product='santa-journey']) h2 {
  color: var(--brand-text-on-blue);
  font-size: var(--type-title) !important;
  line-height: 1.25;
}

body.storybook:is([data-product='reindeer'], [data-product='santa'],
  [data-product='tree-santa'], [data-product='santa-journey']) .product-subheading {
  margin: 0 0 18px;
  font-size: var(--type-subheading) !important;
}

body.storybook[data-product='santa-journey'] :is(.journey-overview small,
  .journey-overview li > span, .journey-tip, .journey-recap-card p,
  .journey-recap-card button, .journey-progress button) {
  font-size: var(--type-quiet) !important;
  line-height: 1.6;
}

/* Older product chrome predates the shared palette. Photos and their guides
   retain their own contrast; gold-filled controls keep readable navy text. */
body.storybook :is(.journey-progress button, .journey-overview li > span,
  .journey-tip, .journey-controls legend, .journey-controls > label,
  .journey-actor-buttons button, .journey-card-placeholder, .journey-recap-card button,
  .magic-capture, .magic-capture-eyebrow, .magic-capture-instruction,
  .magic-capture-status, .magic-capture-error, .magic-capture-fallback,
  .magic-capture-note, .error, footer > span:last-child, .santa-footer > span:nth-of-type(2)) {
  color: var(--brand-text-on-blue);
}

body.storybook .ever-wonder-brand {
  display: flex;
  min-width: 0;
  gap: 12px;
}

body.storybook .ever-wonder-logo {
  display: block;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  object-fit: contain;
  border-radius: 50%;
}

body.storybook .ever-wonder-brand-copy {
  display: block;
  min-width: 0;
}

body.storybook .ever-wonder-name {
  display: block;
  color: var(--cream);
  font-size: var(--type-body, 16px) !important;
  line-height: 1.3;
}

/* The owner's supplied lettering stays an image, independent of UI typography.
   Let compact headers shrink it within the existing ring/navigation budget. */
body.storybook .ever-wonder-wordmark {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  /* Lighten the supplied metallic lettering on navy without replacing its
     artwork, flattening the gradient or changing its transparent edges. */
  filter: brightness(1.55);
}

body.storybook .ever-wonder-slogan {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--type-quiet, 14px) !important;
  line-height: 1.4;
}

body.storybook .ever-wonder-footer-brand {
  display: block;
  margin-bottom: 12px;
}

body.storybook .ever-wonder-footer-brand .ever-wonder-name {
  color: var(--gold-soft);
}

body.storybook :is(.button.primary, .magic-capture-shutter) {
  color: #000518;
  background: var(--brand-accent-gold);
  border-color: var(--gold-soft);
}

body.storybook :is(.button.primary, .magic-capture-shutter):hover:not(:disabled) {
  background: #e7c58d;
}

/* UI panels inherit the blue palette; customer photos and canvases stay intact. */
body.storybook :is(.experience, .experience-journey, .journey-overview, .journey-controls,
  .journey-external-card, .journey-recap-card) {
  background: #030710;
  border-color: var(--line);
}

body.storybook :is(.experience-photo, .experience-journey-photo, .journey-card-media) {
  background: #01040b;
}

body.storybook :is(.journey-progress button, .journey-actor-buttons button) {
  background: #030815;
}

body.storybook .magic-capture {
  background: var(--navy) var(--brand-page-gradient) center / cover no-repeat;
}

body.storybook :is(.tree-canvas-wrap canvas, .journey-canvas-shell canvas,
  .magic-generation-video), body.storybook #plate-canvas {
  background-color: #01040b;
}

body.storybook .magic-capture-status { background-color: #01040bcc; }

@media (max-width: 720px) {
  body.storybook { --type-title: 28px; --type-subheading: 22px; }
  body.storybook .topbar { gap: 12px; }
  body.storybook .ever-wonder-brand { gap: 9px; }
  body.storybook .ever-wonder-logo {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  body.storybook .topbar > :is(.back, a:not(.brand)) {
    max-width: 110px;
    flex: 0 1 auto;
  }
}

@media (max-width: 360px) {
  body.storybook .ever-wonder-logo {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  body.storybook .topbar > :is(.back, a:not(.brand)) { max-width: 84px; }
}

/* Phone reading sizes and full-width experience menu pictures. Sticker choosers
   retain their approved compact grids; no page-scale transform is used. */
@media (max-width: 720px) {
  body.storybook { --type-body: 20px; --type-quiet: 18px; --type-title: 30px; --type-subheading: 24px; }
  body.storybook :is(main, section, fieldset, .stage) { min-width: 0; }
  body.storybook :is(input:not([type='range']):not([type='checkbox']):not([type='radio']), textarea, select) { min-width: 0; max-width: 100%; font-size: 20px !important; }
  body.storybook :is(.button, .back, summary) { max-width: 100%; min-height: 44px; white-space: normal; }
  body.storybook[data-product='experiences'] :is(.category-picker, .category-screen) .category-options { grid-auto-columns: 100%; max-width: 100%; }
  body.storybook[data-product='experiences'] .category-options > * { scroll-snap-align: center; }
  body.storybook[data-product='experiences'] :is(.experience-category, .experience-copy) { text-align: center; }
  body.storybook[data-product='experiences'] .category-options .experience-copy { padding: 16px 0 0; }
  body.storybook[data-product='experiences'] :is(.category-artwork, .category-options .experience-photo) { width: 100%; aspect-ratio: 4 / 3; }
  body.storybook[data-product='santa-journey'] :is(.journey-progress, .journey-recap-cards) { grid-auto-columns: 100%; max-width: 100%; }
  body.storybook[data-product='santa-journey'] :is(.journey-progress, .journey-recap-cards) > * { scroll-snap-align: center; text-align: center; }
}

/* Keep contextual Back and carousel Previous/Next on one navigation row.
   The row stays visible when a single choice needs no carousel controls. */
body.storybook .ew-navigation-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  width: 100%;
  margin-top: 12px;
}
body.storybook .ew-navigation-row > :is(.back, .experience-text-link) {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 48px;
  margin: 0;
}
body.storybook .ew-navigation-row .category-navigation {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0 0 0 auto;
}
body.storybook .ew-navigation-row .category-navigation-actions,
body.storybook .journey-gallery-controls.ew-navigation-row > div {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 16px;
}
body.storybook .ew-navigation-row .category-navigation-actions > button,
body.storybook .journey-gallery-controls.ew-navigation-row > div > button {
  flex: 0 0 auto;
  min-height: 48px;
  white-space: nowrap;
}
body.storybook .journey-gallery-controls.ew-navigation-row > div {
  width: 100%;
  justify-content: space-between;
}
/* Forward/back actions may wrap their labels, never onto separate rows. */
body.storybook .journey-result-actions.ew-navigation-row {
  max-width: 520px;
  margin-inline: auto;
  align-items: stretch;
}
body.storybook .journey-result-actions.ew-navigation-row > .button {
  flex: 1 1 0 !important;
  align-self: stretch;
  margin: 0;
  padding-inline: 14px;
}

/* Owner readability correction: add ivory to the app's gold lettering on navy.
   Keep the supplied artwork and dark lettering on gold-filled buttons intact. */
body.storybook[data-product='experiences'] { color: var(--brand-text-on-blue); }
body.storybook :is(input:not([type='range']):not([type='checkbox']):not([type='radio']):not([type='submit']):not([type='button']):not([type='reset']), textarea, select) {
  color: var(--cream) !important;
}
body.storybook :is(input, textarea)::placeholder {
  color: var(--muted) !important;
  opacity: 1;
}
body.storybook :is(#welcome-story-text, #welcome-intro-text, .intro-instructions p) {
  color: var(--brand-text-on-blue);
}
body.storybook .welcome:is([data-welcome-phase='introduction'],[data-welcome-phase='how-to']) .welcome-actions .back {
  color: var(--gold);
}

/* Approved interface headings retain warm ivory; the remaining interface copy
   now shares it. Keepsake document ink, shared type, dimensions and original
   images remain unchanged. */
body.storybook :is(h1, h2, h3, [role='heading'], .product-heading, .gallery-text-title) {
  color: var(--brand-heading-ink) !important;
}

/* Owner approved the Santa-menu ivory for the remaining interface copy too.
   Keep gold-soft as a surface/accent token, and override its text consumers
   without changing gold artwork, dark filled-button labels or document ink. */
body.storybook :is(.step, .topbar > .back, .topbar > a:not(.brand),
  .experience-navigation a, .template-card .button:not(.primary),
  #anchor-instruction, .text-option[aria-pressed='true'],
  .result-actions .button:not(.primary), .footer-script,
  .ever-wonder-footer-brand .ever-wonder-name, .santa-brand-title,
  .santa-product-name, .santa-tree-link, .santa-picker-status, .santa-loading,
  .santa-frame-tip > span, .santa-frame-tip p, .santa-instruction,
  .tree-brand-title, .tree-visitor-card figcaption, .tree-brightness-value,
  .journey-brand, .journey-intro .product-subheading,
  .journey-intro-copy .support, .journey-menu-pagination,
  .journey-camera-brightness, .magic-capture-close,
  .magic-generation, .ew-download-wait, .ew-download-wait-label,
  .ew-toast, .ew-media-fallback) {
  color: var(--brand-heading-ink) !important;
}
body.storybook .tree-side-options .button[aria-pressed='true']:not(.primary) {
  color: var(--brand-heading-ink);
}

/* These are isolated transparent lettering assets, not photographs. Reuse
   their original alpha as a CSS mask so the precise approved letter shapes,
   layout and accessible image text survive without replacing the source. */
@supports ((mask-image: url('')) or (-webkit-mask-image: url(''))) {
  @supports selector(:has(*)) {
    body.storybook .ever-wonder-name:has(> .ever-wonder-wordmark) { position: relative; }
    body.storybook .ever-wonder-name > .ever-wonder-wordmark { opacity: 0; }
    body.storybook .ever-wonder-name:has(> .ever-wonder-wordmark)::after {
      content: '';
      position: absolute;
      inset: 0 auto 0 0;
      width: min(180px,100%);
      background: var(--brand-heading-ink);
      -webkit-mask: url('/brand/ever-wonder/letter-logo-transparent.svg') left center / contain no-repeat;
      mask: url('/brand/ever-wonder/letter-logo-transparent.svg') left center / contain no-repeat;
      pointer-events: none;
    }
  }
  body.storybook .intro-canva-heading { position: relative; }
  body.storybook .intro-canva-heading > img { opacity: 0; }
  body.storybook .intro-canva-heading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--brand-heading-ink);
    -webkit-mask: url('/brand/ever-wonder/intro-20261019/scene-2-heading-transparent.webp') center / contain no-repeat;
    mask: url('/brand/ever-wonder/intro-20261019/scene-2-heading-transparent.webp') center / contain no-repeat;
    pointer-events: none;
  }
}
