/* Dossier table: the /guides/ index rebuilt as intelligence folders cast on
   a table. Owned by the dossier lane. Copied verbatim to
   public/guides/assets/dossier.css by scripts/build-guides.mjs and linked
   from the generated pages' <head> (one <link>, nothing else added there).
   Design tokens are read from src/styles.css custom properties, which this
   file assumes are already in scope (guide.css defines :root the same way,
   so both stylesheets agree on --bg/--surface/--text/--muted/--accent/--line).

   Grammar: a folder is a single link. A tab carries the field-note number.
   A taped photo is the thumbnail. A rubber stamp carries the pack name.
   Title and dek are typed, monospace. Deterministic rotation makes the set
   read as cast on a table rather than a tidy grid; hover/focus straightens
   and lifts one folder at a time. */

.dossier-table {
  position: relative;
  padding: 56px 0 72px;
  background-color: #0a0d09;
  background-image:
    radial-gradient(ellipse 62% 46% at 50% 28%, rgba(255, 214, 140, 0.16) 0%, rgba(255, 214, 140, 0.05) 45%, transparent 72%),
    linear-gradient(180deg, rgba(10, 13, 9, 0.42) 0%, rgba(10, 13, 9, 0.28) 40%, rgba(10, 13, 9, 0.58) 100%),
    url("/images/table/table-map-protractor-1600.webp");
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  isolation: isolate;
}
@media (min-width: 1400px) {
  .dossier-table {
    background-image:
      radial-gradient(ellipse 62% 46% at 50% 28%, rgba(255, 214, 140, 0.16) 0%, rgba(255, 214, 140, 0.05) 45%, transparent 72%),
      linear-gradient(180deg, rgba(10, 13, 9, 0.42) 0%, rgba(10, 13, 9, 0.28) 40%, rgba(10, 13, 9, 0.58) 100%),
      url("/images/table/table-map-protractor-2560.webp");
  }
}
.dossier-table::before {
  /* table-edge vignette, on top of the photographic vignette already baked
     into the source image, so the folders always sit in the readable middle */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  box-shadow: inset 0 0 18vw rgba(0, 0, 0, 0.5);
}

.dossier-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 34px 26px;
  padding-inline: 4px;
}
@media (min-width: 1100px) {
  /* Break the rigid 4-up grid a little: a deterministic per-card vertical
     wobble driven by the same --i index used for --tilt, plus an
     occasional deliberate overlap into the row above. Desktop only. */
  .dossier-grid > .dossier {
    --offset: calc(sin(var(--i, 0) * 1rad) * 16px);
  }
  .dossier-grid > .dossier:nth-child(8n + 3) {
    --offset: calc(sin(var(--i, 0) * 1rad) * 16px - 34px);
    z-index: 2;
  }
}
@media (max-width: 1080px) {
  .dossier-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px 20px;
  }
}
@media (max-width: 600px) {
  .dossier-grid {
    grid-template-columns: 1fr;
    gap: 22px;
    padding-inline: 0;
  }
}

.dossier {
  --tilt: 0deg;
  --offset: 0px;
  --cut: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  /* Round 3: folders trimmed ~30% smaller (padding, photo, type below) so a
     dossier band shows more of the imagery behind it and less manila. */
  padding: 11px 11px 13px;
  background: linear-gradient(165deg, #cdc09a 0%, #b9ac82 55%, #a89970 100%);
  border: 1px solid #7d7150;
  border-radius: 3px 3px 4px 4px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 14px 26px rgba(0, 0, 0, 0.55),
    0 3px 6px rgba(0, 0, 0, 0.4);
  color: #211d12;
  text-decoration: none;
  transform: rotate(var(--tilt)) translateY(var(--offset));
  transform-origin: 50% 40%;
  transition: transform 190ms ease, box-shadow 190ms ease;
  outline-offset: 3px;
}
.dossier::before {
  /* manila fibre texture, cheap and deterministic: two overlaid faint
     diagonal noise-ish gradients rather than a shipped texture image */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    repeating-linear-gradient(115deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(25deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 7px);
  mix-blend-mode: multiply;
  pointer-events: none;
}
.dossier:hover,
.dossier:focus-visible {
  transform: rotate(0deg) translateY(calc(var(--offset) - 6px)) scale(1.015);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 26px 40px rgba(0, 0, 0, 0.6),
    0 6px 12px rgba(0, 0, 0, 0.45);
  z-index: 3;
}
.dossier:focus-visible {
  outline: 2px solid var(--accent);
}

.dossier__tab {
  position: absolute;
  top: -14px;
  left: 18px;
  padding: 4px 12px 5px;
  background: #6b7a4e;
  color: #eef2e2;
  border: 1px solid #4d5836;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  font: 700 10px/1 "Roboto Mono", Consolas, "Courier New", monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.15) inset;
}

.dossier__photo {
  position: relative;
  display: block;
  margin: 7px 0 8px;
  padding: 4px 4px 15px;
  background: #f2efe4;
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.08);
  transform: rotate(-1.1deg);
  isolation: isolate;
}
.dossier__photo::after {
  /* a strip of tape across one corner */
  content: "";
  position: absolute;
  top: -9px;
  right: 14%;
  width: 58px;
  height: 22px;
  background: rgba(224, 214, 176, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transform: rotate(-6deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.dossier__photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.03);
}

.dossier__stamp {
  /* Nested inside .dossier__photo (see markup): lands on the cream paper
     mount strip below the image, not on the photo itself, so it reads as
     an ink stamp on the folder paper rather than vanishing into a dark
     screenshot. */
  position: absolute;
  top: auto;
  bottom: 1px;
  right: 8px;
  z-index: 1;
  padding: 3px 9px;
  border: 2px solid rgba(150, 42, 32, 0.72);
  border-radius: 4px;
  background: rgba(150, 42, 32, 0.05);
  color: rgba(150, 42, 32, 0.82);
  font: 800 11px/1 "Roboto Mono", Consolas, "Courier New", monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-8deg);
  mix-blend-mode: multiply;
  pointer-events: none;
  opacity: 0.85;
}

.dossier__title {
  margin: 2px 0 3px;
  font: 700 13px/1.25 "Roboto Mono", Consolas, "Courier New", monospace;
  letter-spacing: 0.01em;
  color: #201c11;
}
.dossier__dek {
  margin: 0;
  font: 11px/1.45 "Roboto Mono", Consolas, "Courier New", monospace;
  color: #4a4531;
}
:lang(th) .dossier__title,
:lang(zh-CN) .dossier__title,
:lang(hi) .dossier__title {
  font-family: var(--ui);
  letter-spacing: 0.01em;
}
:lang(th) .dossier__dek,
:lang(zh-CN) .dossier__dek,
:lang(hi) .dossier__dek {
  font-family: var(--ui);
}

/* Field notes further back in the stack, a touch smaller, to reinforce the
   "cast down" feel without an actual z-axis. */
.dossier--featured {
  grid-column: span 2;
}
.dossier--featured .dossier__photo img {
  aspect-ratio: 16 / 9;
}
@media (max-width: 900px) {
  .dossier--featured {
    grid-column: span 1;
  }
}

.dossier--incoming {
  background: linear-gradient(165deg, #8b8264 0%, #726a4c 55%, #635c40 100%);
  border-style: dashed;
  color: #efeee2;
}
.dossier--incoming .dossier__tab {
  background: #4a4334;
  border-color: #2f2a20;
}
.dossier--incoming .dossier__title {
  color: #f2f1e6;
}
.dossier--incoming .dossier__dek {
  color: #cfccb8;
}
.dossier--incoming .dossier__stamp {
  border-color: rgba(179, 208, 135, 0.85);
  color: rgba(179, 208, 135, 0.9);
}
.dossier--incoming .dossier__photo img {
  filter: saturate(0.55) contrast(1.02) brightness(0.85);
}

/* Case-file header strip: each guide page's own hero, dressed the same way
   as the index folders so the set reads as one series end to end. */
.case-file-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 22px;
  align-items: center;
  padding: 18px 22px;
  margin-block: 4px 30px;
  background: linear-gradient(165deg, #1a2016 0%, #141810 100%);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.case-file-header__photo {
  position: relative;
  padding: 6px 6px 16px;
  background: #f2efe4;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transform: rotate(1.2deg);
}
.case-file-header__photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.03);
}
.case-file-header__meta {
  font: 11px/1.5 "Roboto Mono", Consolas, "Courier New", monospace;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
@media (max-width: 720px) {
  .case-file-header {
    grid-template-columns: 1fr;
  }
  .case-file-header__photo {
    order: -1;
    max-width: 220px;
  }
}

/* Related field notes: reuses the same folder markup at the foot of a guide
   page, three across, no incoming-pack styling there. */
.dossier-related {
  margin-top: 46px;
}
.dossier-related h2 {
  font: 11px/1.4 "Roboto Mono", Consolas, "Courier New", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.dossier-related .dossier-grid {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) {
  .dossier-related .dossier-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Three related notes in two columns: centre the third. */
  .dossier-related .dossier-grid > .dossier:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 10px);
  }
}
@media (max-width: 600px) {
  .dossier-related .dossier-grid {
    grid-template-columns: 1fr;
  }
  .dossier-related .dossier-grid > .dossier:last-child:nth-child(odd) {
    grid-column: auto;
    justify-self: stretch;
    width: auto;
  }
}

@media (max-width: 600px) {
  .dossier {
    --tilt: 0deg !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dossier {
    --tilt: 0deg !important;
    transition: none;
  }
  .dossier:hover,
  .dossier:focus-visible {
    transform: none;
  }
}


/* Compact folder for bands/rows where the imagery behind needs to breathe:
   ~180-220px wide on desktop, two across on phones, photo shrunk further,
   dek dropped so only the tab and title carry the intel. */
.dossier--mini {
  width: clamp(150px, 22vw, 210px);
  padding: 8px 8px 10px;
}
.dossier--mini .dossier__tab {
  font-size: 8px;
  padding: 3px 8px 4px;
  top: -11px;
}
.dossier--mini .dossier__photo {
  margin: 6px 0 6px;
  padding: 3px 3px 11px;
}
.dossier--mini .dossier__stamp {
  font-size: 9px;
  padding: 2px 6px;
}
.dossier--mini .dossier__title {
  font-size: 11px;
  margin-bottom: 0;
}
.dossier--mini .dossier__dek {
  display: none;
}
.dossier__date {
  display: block;
  margin: 0 0 2px;
  font: 10px/1.3 "Roboto Mono", Consolas, "Courier New", monospace;
  color: #7a744f;
  letter-spacing: 0.03em;
}
.dossier--mini .dossier__date {
  font-size: 9px;
}
.dossier-row--mini {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 14px;
  position: relative;
  z-index: 1;
}
@media (max-width: 600px) {
  .dossier--mini {
    width: calc(50% - 7px);
  }
}

/* Field-note index: keep the dossier language, but give every title enough
   room to read on desktop and on a narrow phone. */
.dossier-grid--dense {
  /* Layout symmetry pass: sized by the shared container (.wrap), not a
     private 1500px cap; flex + centred wrap so a final partial row is
     centred rather than left-stranded. --c is the column count per
     breakpoint. */
  --c: 2;
  --gx: var(--wm-card-gap, 20px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 25px var(--gx);
}
.dossier-grid--dense > .dossier--mini {
  flex: 0 0 calc((100% - (var(--c) - 1) * var(--gx)) / var(--c));
  width: auto;
  max-width: none;
  padding: 11px 11px 14px;
}
.dossier-grid--dense > .dossier--featured {
  flex-basis: calc((100% - (var(--c) - 1) * var(--gx)) / var(--c));
}
@media (min-width: 901px) {
  .dossier-grid--dense > .dossier--featured {
    flex-basis: calc(2 * (100% - (var(--c) - 1) * var(--gx)) / var(--c) + var(--gx));
  }
}
.dossier-grid--dense .dossier__title {
  font-size: 13px;
  line-height: 1.35;
}
@media (min-width: 640px) {
  .dossier-grid--dense { --c: 3; }
}
@media (min-width: 1050px) {
  .dossier-grid--dense { --c: 4; }
}
@media (min-width: 1700px) {
  .dossier-grid--dense { --c: 5; }
}
