/* Cream stock and a deliberately uneven ink line. Layout lives in immersive.css.
   The little paper faces are smaller than their transparent pointer targets. */
.immersive {
  --comic-lettering: 'Chalkboard SE', 'Comic Sans MS', 'Comic Sans', Georgia, serif;
  --comic-paper-face: url('assets/ui/paper-tab.svg');
  --comic-paper-border: url('assets/ui/paper-border.svg');
  --comic-ink-rule: url('assets/ui/ink-rule.svg');
  --comic-secondary-ink: #62543b;
}

/* Keep one SVG image attached for the entire motion session. Its resident ink
   paths redraw every half-second; the paper/grain never change. Replacing CSS
   image URLs on each frame can flash on mobile Safari, even after decode(). */
@media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  .immersive[data-paper-motion='playing'] {
    --comic-paper-face: url('assets/ui/paper-tab-motion.svg');
    --comic-paper-border: url('assets/ui/paper-border-motion.svg');
  }
}

.immersive :is(.controls-toggle, .control, .control.primary, .camera-button, .camera-track, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card) {
  position: relative;
  isolation: isolate;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-family: var(--comic-lettering);
  text-decoration: none;
}
.immersive :is(.controls-toggle, .control, .camera-button, .camera-track, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card)::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: var(--paper-inset-y, 0) var(--paper-inset-x, 0);
  border: 0;
  background: var(--comic-paper-face) center / 100% 100% no-repeat;
  transform: rotate(var(--paper-tilt, -.35deg));
  transform-origin: center;
  filter: drop-shadow(1px 1px 0 #091d206b);
  pointer-events: none;
}
.immersive .controls-toggle { --paper-inset-y: 11px; --paper-inset-x: 9px; --paper-tilt: -2deg; }
.immersive .close-button { --paper-inset-y: 20%; --paper-inset-x: 22%; --paper-tilt: 2deg; }
.immersive .control:nth-child(even),
.immersive .camera-button:nth-child(even),
.immersive .find-list button:nth-child(even),
.immersive .suggestions button:nth-child(even) { --paper-tilt: .5deg; }
.immersive .control.primary { font-weight: 700; }
.immersive .control span,
.immersive .layers-link span { color: currentColor; }
.immersive .control[aria-pressed='false'] { color: var(--comic-secondary-ink); }
.immersive .control[aria-pressed='true'] { color: #244d41; }
.immersive :is(.controls-toggle, .control, .control.primary, .camera-button, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card):hover:not(:disabled),
.immersive .camera-track:hover {
  color: var(--ink);
  border-color: transparent;
  background: transparent;
}
.immersive :is(.controls-toggle, .control, .camera-button, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card):hover:not(:disabled)::before,
.immersive .camera-track:hover::before {
  filter: brightness(1.055) drop-shadow(1px 2px 0 #091d207a);
}
.immersive :is(.controls-toggle, .control, .control.primary, .camera-button, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card):active:not(:disabled) {
  background: transparent;
  color: var(--ink);
}
.immersive :is(.controls-toggle, .control, .camera-button, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card):active:not(:disabled)::before {
  filter: brightness(.96);
}
.immersive :is(.control, .camera-button, .paper-button, .send-button):disabled { opacity: .6; }
.immersive .comic-link svg { stroke: currentColor; }
.immersive :is(.controls-toggle, .camera-button) svg { stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

/* Nine-slice borders keep the ink weight stable on both brief notes and readers.
   The stock starts inside the border, so no square background corners show. */
.immersive :is(.speech, .scene-note, .find-panel, .newsstand-dialog, .object-tag, .skip-link, .noscript-note) {
  border: 7px solid transparent;
  border-image: var(--comic-paper-border) 12 / 7px / 0 stretch;
  border-radius: 0;
  color: var(--ink);
  background: var(--paper-light);
  background-clip: padding-box;
  box-shadow: none;
  /* Keep text and form fields out of a whole-panel filter surface. */
  filter: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  --scrollbar-thumb: #81704e;
  --scrollbar-track: #e5d2aa;
}
.immersive :is(.speech, .scene-note, .find-panel, .newsstand-dialog) {
  background-image: radial-gradient(#6c543c0e .55px, transparent .7px);
  background-size: 13px 17px;
  background-origin: padding-box;
}
.immersive .object-tag {
  border-width: 4px;
  border-image-width: 4px;
  font-family: var(--comic-lettering);
  font-weight: 700;
  filter: none;
}
.immersive :is(.eyebrow, .reply, .scene-note p, .suggestions, .chat-form input, .fineprint, .chat-status, .shelf-status, .reader-tools p, .reader-navigation p, .issue-card span) { font-family: var(--comic-lettering); }
.immersive .eyebrow { letter-spacing: .9px; }
.immersive :is(.speaker, .scene-note .eyebrow, .find-panel .eyebrow, .newsstand-top .eyebrow) { color: #704d2a; }
.immersive :is(.fineprint, .chat-status, .shelf-status, .last-message, .shelf-empty p, .issue-card span) { color: var(--comic-secondary-ink); }
.immersive .find-list button { border: 0; }
.immersive .chat-form input {
  border: 5px solid transparent;
  border-image: var(--comic-paper-border) 12 / 5px / 0 stretch;
  border-radius: 0;
  color: var(--ink);
  background: #fff4d8;
  background-clip: padding-box;
  box-shadow: none;
  caret-color: var(--ink);
}
.immersive .chat-form input::placeholder { color: #706146; }
.immersive .send-button { font-weight: 700; }
.immersive .newsstand-dialog::backdrop { background: #101c1f91; backdrop-filter: none; }
.immersive .newsstand-top {
  border-bottom: 0;
  background: var(--comic-ink-rule) left bottom / 100% 4px no-repeat;
}
.immersive .empty-rule { background: var(--comic-ink-rule) center / 100% 100% no-repeat; }

/* A pencilled line and an ink thumb, rather than a luminous UI track. */
.immersive .camera-track { font-family: var(--comic-lettering); }
.immersive .camera-track input { color-scheme: light; }
.immersive .camera-track input::-webkit-slider-runnable-track { border-radius: 0; background: var(--comic-ink-rule) center / 100% 100% no-repeat; }
.immersive .camera-track input::-moz-range-track { border-radius: 0; background: var(--comic-ink-rule) center / 100% 100% no-repeat; }
.immersive .camera-track input::-webkit-slider-thumb { border-color: var(--ink); border-radius: 28% 12% 32% 9% / 16% 34% 11% 28%; background: var(--ink); box-shadow: none; transform: rotate(-4deg); }
.immersive .camera-track input::-moz-range-thumb { border-color: var(--ink); border-radius: 28% 12% 32% 9% / 16% 34% 11% 28%; background: var(--ink); box-shadow: none; transform: rotate(-4deg); }

/* The high-contrast focus marks stay outside the lettering and are never clipped
   into the paper shape. The actual pointer targets retain the layout's size. */
.immersive :is(.controls-toggle, .scene-tools button, .scene-tools a):focus-visible,
.immersive .camera-track:focus-within { outline: 2px dashed var(--paper-light); outline-offset: -1px; }
.immersive :is(.speech, .scene-note, .find-panel, .newsstand-dialog) :is(button, a, input):focus-visible { outline: 2px dashed var(--ink); outline-offset: -2px; }
.immersive .scene-object:focus-visible { outline-color: var(--paper-light); border-radius: 8% 2% 10% 3% / 3% 8% 4% 9%; }

@media (forced-colors: active) {
  .immersive :is(.controls-toggle, .control, .control.primary, .camera-button, .camera-track, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card) { color: ButtonText; }
  .immersive :is(.controls-toggle, .control, .camera-button, .camera-track, .layers-link, .close-button, .suggestions button, .send-button, .paper-button, .find-list button, .issue-card)::before { background: Canvas; border: 1px solid ButtonText; filter: none; }
  .immersive :is(.speech, .scene-note, .find-panel, .newsstand-dialog, .object-tag, .skip-link, .noscript-note, .chat-form input) { border-image: none; border-color: CanvasText; background: Canvas; color: CanvasText; filter: none; }
  .immersive .camera-track input { appearance: auto; -webkit-appearance: auto; }
  .immersive .camera-button:disabled { opacity: 1; color: GrayText; }
  .immersive :is(button, a, input):focus-visible,
  .immersive .camera-track:focus-within { outline-color: Highlight; }
}
