/* Paper theme: the light editorial system shared by the rebuilt pages
 * (Card Sequence, Search, Set Sequence): tokens and shell overrides scoped to
 * body.page-paper, plus the components those pages share (tones, the sequence
 * chart from 04-sequence.js, the card tile from 04-card-tile.js). The tokens
 * move into tokens.css once the whole shell adopts the direction. */

body.page-paper {
  --paper: #f4efe4;
  --paper-deep: #ebe4d3;
  --ink: #1d1b16;
  --ink-2: #514c3e;
  --ink-3: #837d6c;
  --rule: #d5ccb6;
  --up: #2b6a3c;
  --down: #a1302a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  background: var(--paper);
}

/* Card-stock texture on the root: an ordinary scrolling page background, so
 * the paper moves with the content as if the page were printed on it.
 * (A fixed background or fixed layer stays put while content slides over it,
 * and a fixed background is repainted on every scroll step.) The body is
 * transparent so the root background shows; browsers without :has() keep the
 * plain paper colour on the body. */
@supports selector(html:has(body)) {
  html:has(body.page-paper) {
    /* Card-stock texture, generated in CSS (inline SVG noise, no image files).
     * Layers at unrelated tile sizes so nothing visibly repeats, top to bottom:
     * sparse specks and fibres; fine grain; cloudy fibre mottling; soft crumple
     * relief (lit noise: faint shadow and highlight ridges); a tonal wash.
     * Tune strength through each layer's alpha row (the 4th row of feColorMatrix). */
    --paper-specks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='431' height='389'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.36' numOctaves='1' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .44 0 0 0 0 .37 0 0 0 0 .25 0 0 0 7 -5.26'/%3E%3C/filter%3E%3Cfilter id='f'%3E%3CfeTurbulence type='turbulence' baseFrequency='.009 .04' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .34 0 0 0 0 .25 0 0 0 1.6 -1.08'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23s%29'/%3E%3Crect width='100%25' height='100%25' filter='url%28%23f%29'/%3E%3C/svg%3E");
    --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='223' height='223'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .33 0 0 0 0 .28 0 0 0 0 .2 0 0 0 .22 -.07'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23g%29'/%3E%3C/svg%3E");
    --paper-mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='613' height='557'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.035' numOctaves='4' seed='29' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .4 0 0 0 0 .32 0 0 0 .15 -.05'/%3E%3C/filter%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.05' numOctaves='3' seed='31' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 .98 0 0 0 .2 -.07'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23m%29'/%3E%3Crect width='100%25' height='100%25' filter='url%28%23w%29'/%3E%3C/svg%3E");
    --paper-crumple: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='352' height='274'%3E%3Cfilter id='c' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='turbulence' baseFrequency='.0084 .0116' numOctaves='2' seed='41' stitchTiles='stitch'/%3E%3CfeGaussianBlur stdDeviation='2.2'/%3E%3CfeDiffuseLighting surfaceScale='9' lighting-color='%23fff'%3E%3CfeDistantLight azimuth='225' elevation='60'/%3E%3C/feDiffuseLighting%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .26 0 0 0 0 .2 -.8 0 0 0 .66'/%3E%3C/filter%3E%3Cfilter id='h' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='turbulence' baseFrequency='.0084 .0116' numOctaves='2' seed='41' stitchTiles='stitch'/%3E%3CfeGaussianBlur stdDeviation='2.2'/%3E%3CfeDiffuseLighting surfaceScale='9' lighting-color='%23fff'%3E%3CfeDistantLight azimuth='225' elevation='60'/%3E%3C/feDiffuseLighting%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 .99 .95 0 0 0 -.84'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23c%29'/%3E%3Crect width='100%25' height='100%25' filter='url%28%23h%29'/%3E%3C/svg%3E");
    background-color: #f4efe4;
    background-image:
      var(--paper-specks),
      var(--paper-grain),
      var(--paper-mottle),
      var(--paper-crumple),
      radial-gradient(ellipse 70% 55% at 16% 10%, rgba(255, 253, 247, 0.4), transparent 70%);
    /* The crumple relief is rendered at quarter size and upscaled: smooth folds, no banding. */
    background-size: auto, auto, auto, 1408px 1096px, auto;
  }

  body.page-paper {
    background: transparent;
  }
}

/* The shell is transparent so the card-stock texture shows through. */
body.page-paper .app-shell,
body.page-paper .main {
  background: transparent;
  color: var(--ink);
}

/* Toolbar controls sit on paper: plain outlines on a solid fill (the toolbar is sticky), no glass. */
body.page-paper .side-nav-toggle,
body.page-paper .main-toolbar-currency .browser-combobox-shell,
body.page-paper .mobile-card-detail-back {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  box-shadow: none;
  backdrop-filter: none;
}

body.page-paper .global-footer {
  margin-top: 8px;
  padding: 20px 0 0;
  border: 0;
  border-top: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--ink-3);
}

body.page-paper .global-footer a {
  color: var(--ink-2);
}

body.page-paper .main-toolbar-currency input,
body.page-paper .main-toolbar-currency .browser-combobox-icon,
body.page-paper .main-toolbar-currency .currency-combobox-toggle,
body.page-paper .side-nav-toggle-label {
  color: var(--ink);
}

body.page-paper .side-nav-toggle-icon span {
  background: var(--ink);
}

/* Narrow-screen bottom navigation: a docked strip of paper under a thin rule,
 * not a floating dark pill. The active page is marked by ink and a rule. */
body.page-paper .mobile-nav {
  left: 0;
  right: 0;
  bottom: 0;
  gap: 0;
  padding: 0 max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
  border: 0;
  border-top: 1px solid var(--rule);
  border-radius: 0;
  background: var(--paper);
  box-shadow: none;
  backdrop-filter: none;
}

body.page-paper .mobile-nav .nav-item {
  min-height: 56px;
  padding: 8px 4px 7px;
  border: 0;
  border-top: 2px solid transparent;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--ink-3);
}

body.page-paper .mobile-nav .nav-item:hover {
  background: none;
  border-color: transparent;
  color: var(--ink);
}

body.page-paper .mobile-nav .nav-item.is-active {
  border-top-color: var(--ink);
  background: none;
  box-shadow: none;
  color: var(--ink);
}

body.page-paper .mobile-nav-label {
  font-weight: 600;
  letter-spacing: 0.02em;
}

@media (max-width: 1090px) {
  body.page-paper .main {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* ---------- shared components ---------- */

.is-up { color: var(--up); }
.is-down { color: var(--down); }
.is-flat { color: var(--ink-2); }

.sq-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 24px;
  margin-bottom: 8px;
}

.sq-readout {
  margin: 0;
  min-height: 24px;
  color: var(--ink-2);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.sq-readout strong {
  margin-left: 8px;
  font-weight: 600;
}

.sq-ranges {
  display: flex;
  gap: 18px;
}

.sq-ranges button {
  padding: 2px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-3);
  font: 500 14px/1.2 "IBM Plex Sans", sans-serif;
  cursor: pointer;
}

.sq-ranges button[aria-pressed="true"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.sq-chart-wrap {
  margin: 0 -2px;
}

.sq-chart {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
  overflow: visible;
}

.sq-grid { stroke: var(--rule); stroke-width: 1; }
.sq-tick { stroke: var(--rule); stroke-width: 1; }
.sq-axis { fill: var(--ink-3); font: 400 12px "IBM Plex Sans", sans-serif; }
.sq-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sq-mark-peak { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.sq-mark-now { fill: var(--ink); }
.sq-mark-move { fill: var(--paper); stroke: var(--down); stroke-width: 2; }
.sq-note-move { fill: var(--down); font-weight: 500; font-size: 12px; }
.sq-note {
  fill: var(--ink);
  font: 600 13px "IBM Plex Sans", sans-serif;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
}
.sq-cursor-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.sq-cursor-dot { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.sq-hit { fill: transparent; cursor: crosshair; }
.sq-baseline { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 4; }
.sq-mark-start { fill: var(--paper); stroke: var(--ink-3); stroke-width: 2; }
.sq-note-start { fill: var(--ink-2); font-weight: 500; }

/* Card tile (04-card-tile.js): artwork first, then name, meta and price. */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 30px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  min-width: 0;
}

.tile-link {
  display: grid;
  gap: 3px;
  color: inherit;
  text-decoration: none;
}

.tile-art {
  display: block;
  aspect-ratio: 5 / 7;
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 4.5% / 3.2%;
  background: var(--paper-deep);
}

.tile-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 160ms ease;
}

.tile-link:hover .tile-art img {
  transform: translateY(-2px);
}

.tile-name {
  display: -webkit-box;
  overflow: hidden;
  font: 600 17px/1.25 var(--serif);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.tile-link:hover .tile-name {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.tile-meta {
  overflow: hidden;
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tile-price {
  margin-top: 4px;
  font: 600 16px/1.2 "IBM Plex Sans", sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
}

.tile-price-observed {
  color: var(--ink-3);
}

.tile-price-note {
  font-weight: 400;
  font-size: 12px;
}

.tile-price-none {
  color: var(--ink-3);
  font-weight: 400;
}

.tile-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

@media (max-width: 760px) {
  .tile-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 24px 14px;
    }

  .tile-name {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-art img {
    transition: none;
  }
}
