/* ============================================================
   TOWN FOLDER — D-format evidence folder for town pages
   A-material system: charcoal folder bodies, hairline bezels,
   grain, Fraunces tab labels, Space Mono forensic kickers.
   Water is always teal (#38ccdf). Evidence red #ec5548.
   Modes:
     default (no JS / reduced motion / mobile) — folder pre-opened,
       sheets in a static grid. Fully readable, links are plain <a>.
     html.tf-armed (JS + motion + >640px) — desk scene, closed cover,
       GSAP swings the cover open (rotateX) and fans the sheets out;
       sheets are draggable with inertia.
   ============================================================ */

.tf-scene {
  max-width: var(--container, 78rem);
  margin: 0 auto;
  padding: 1.1rem var(--gut, 1.5rem) 0.4rem;
}

/* ── double-bezel desk panel ───────────────────────────────── */
.tf-desk {
  border: 1px solid rgba(242, 239, 232, 0.10);
  border-radius: 18px;
  padding: 10px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(56, 204, 223, 0.06), transparent 55%),
    radial-gradient(100% 90% at 90% 110%, rgba(236, 85, 72, 0.045), transparent 60%),
    #0a2529;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55),
              inset 0 1px 0 rgba(242, 239, 232, 0.07);
}
.tf-desk-inner {
  position: relative;
  border: 1px solid rgba(242, 239, 232, 0.10);
  border-radius: 12px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(56, 204, 223, 0.045), transparent 55%),
    radial-gradient(100% 100% at 82% 100%, rgba(236, 85, 72, 0.05), transparent 60%),
    #0a2529;
  box-shadow: inset 0 1px 0 rgba(242, 239, 232, 0.07);
  overflow: clip;
  padding: 1.4rem 1.2rem 1.6rem;
  perspective: 1400px;
}
.tf-grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 6; opacity: 0.9;
  background-image: repeating-linear-gradient(0deg, transparent 0 2px, rgba(242, 239, 232, 0.015) 2px 3px);
}

/* ── the folder ────────────────────────────────────────────── */
.tf-folder {
  position: relative;
  width: min(560px, 100%);
  margin: 34px auto 1.6rem;
  transform-style: preserve-3d;
  /* view-transition-name removed (freeze) */
}
.tf-folder-back {
  position: absolute; inset: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #16383b, #0e3034);
  border: 1px solid rgba(242, 239, 232, 0.14);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
/* curved-shoulder tab — drawn with an SVG path, label overlaid */
.tf-tab {
  position: absolute; top: -32px; left: 6%;
  height: 32px; min-width: 168px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 1.5rem 0.15rem;
  filter: drop-shadow(0 -4px 10px rgba(0, 0, 0, 0.35));
}
.tf-tab-shape {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.tf-tab-label {
  position: relative; z-index: 1;
  font-family: var(--display, "Fraunces", serif);
  font-weight: 600; font-size: 0.98rem; letter-spacing: 0.02em;
  color: #f2efe8;
}
/* thin accent strip along the folder's top edge (accent as trim, never a fill) */
.tf-cover::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(90deg, rgba(236, 85, 72, 0.85), rgba(236, 85, 72, 0.25));
}
.tf-cover {
  position: relative;
  border-radius: 10px;
  background:
    radial-gradient(140% 90% at 50% 110%, rgba(236, 85, 72, 0.07), transparent 55%),
    linear-gradient(180deg, #183a35, #0e3034);
  border: 1px solid rgba(242, 239, 232, 0.14);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(242, 239, 232, 0.07);
  min-height: 150px;
  display: flex; align-items: flex-end;
  padding: 1.25rem;
  transform-origin: 50% 0%;
  will-change: transform;
  backface-visibility: hidden;
}
.tf-stamp {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.63rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(242, 239, 232, 0.55);
  border: 1px solid rgba(242, 239, 232, 0.14);
  border-radius: 4px; padding: 0.55rem 0.75rem;
  line-height: 1.7;
}
.tf-stamp b {
  display: block;
  font-family: var(--display, "Fraunces", serif);
  font-weight: 650; font-size: 1.05rem; letter-spacing: 0.02em;
  text-transform: none; color: #f2efe8;
}
.tf-open-hint { display: none; color: #f4685c; }
html.tf-armed .tf-open-hint { display: inline; }
html.tf-armed .tf-cover { cursor: pointer; }
.tf-tie {
  position: absolute; right: 1.15rem; top: 1.05rem;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(242, 239, 232, 0.2);
}
.tf-tie::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  border: 1px solid rgba(236, 85, 72, 0.55);
}

/* ── evidence sheets — static grid by default ──────────────── */
.tf-sheets {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.1rem;
  align-items: start;
}
.tf-sheet {
  position: relative;
  /* A-material dark document sheet: charcoal with a faint warm cast + a
     hairline top edge, so it reads as a paper prop on the dark desk WITHOUT
     a cream/parchment background (client: A's colors, no parchment). */
  background: linear-gradient(178deg, #16342f, #0e302e);
  color: var(--paper, #f2efe8);
  border: 1px solid rgba(242, 239, 232, 0.10);
  border-top: 1px solid rgba(242, 239, 232, 0.16);
  border-radius: 4px;
  padding: 1.8rem 1.1rem 1.15rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
  font-family: var(--sans, "Space Grotesk", sans-serif);
}
.tf-sheet:focus-visible {
  outline: 2px solid #38ccdf;
  outline-offset: 3px;
}
.tf-sheet.is-front {
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.65), 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 5;
}
.tf-kicker {
  display: flex; justify-content: space-between; gap: 0.5rem;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(242, 239, 232, 0.55);
  border-bottom: 1px solid rgba(242, 239, 232, 0.10);
  padding-bottom: 0.45rem; margin: 0 0 0.6rem;
}
.tf-sheet h3 {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.9rem; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase; line-height: 1.35;
  margin: 0 0 0.5rem; color: var(--paper, #f2efe8);
}
.tf-sheet p { font-size: 0.83rem; line-height: 1.55; color: rgba(242, 239, 232, 0.72); margin: 0 0 0.5rem; }
.tf-chip {
  display: inline-block;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: #ec5548; border: 1px solid rgba(236, 85, 72, 0.5);
  border-radius: 3px; padding: 0.18rem 0.45rem;
  margin-bottom: 0.55rem;
}
.tf-stamp-red {
  position: absolute; right: 0.8rem; bottom: 2.5rem;
  transform: rotate(-11deg);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(236, 85, 72, 0.8);
  border: 2px solid rgba(236, 85, 72, 0.55);
  border-radius: 3px; padding: 0.2rem 0.5rem;
  pointer-events: none;
}
.tf-clip {
  position: absolute; top: -13px; left: 20px;
  width: 24px; height: 50px; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}
.tf-sheet-list { list-style: none; margin: 0 0 0.55rem; padding: 0; }
.tf-sheet-list li {
  display: flex; gap: 0.6rem; align-items: baseline;
  font-size: 0.8rem; line-height: 1.45; color: rgba(242, 239, 232, 0.78);
  padding: 0.32rem 0;
  border-bottom: 1px dashed rgba(242, 239, 232, 0.10);
}
.tf-sheet-list li:last-child { border-bottom: none; }
.tf-sheet-list time, .tf-sheet-list .tf-li-date {
  flex: none;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(242, 239, 232, 0.5); padding-top: 0.1em;
}
.tf-sheet-list a { color: var(--paper, #f2efe8); text-decoration: none; border-bottom: 1px solid rgba(236, 85, 72, 0.45); }
.tf-sheet-list a:hover, .tf-sheet-list a:focus-visible { color: #ec5548; }
.tf-sheet-link {
  display: inline-block;
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: #bf2e27; text-decoration: none;
  border-bottom: 1px solid rgba(191, 46, 39, 0.45);
  padding-bottom: 1px;
}
.tf-sheet-link:hover, .tf-sheet-link:focus-visible { color: #8f221d; border-bottom-color: currentColor; }

/* dark prop sheet — the map excerpt */
.tf-sheet--dark {
  background: linear-gradient(178deg, #0e3236, #092428);
  color: #f2efe8;
  border: 1px solid rgba(242, 239, 232, 0.10);
}
.tf-sheet--dark .tf-kicker { color: rgba(242, 239, 232, 0.55); border-bottom-color: rgba(242, 239, 232, 0.10); }
.tf-sheet--dark h3 { color: #f2efe8; }
.tf-sheet--dark p { color: rgba(242, 239, 232, 0.72); }
.tf-sheet--dark .tf-sheet-link { color: #38ccdf; border-bottom-color: rgba(56, 204, 223, 0.45); }
.tf-sheet--dark .tf-sheet-link:hover, .tf-sheet--dark .tf-sheet-link:focus-visible { color: #7fe0ee; }
.tf-tape {
  position: absolute; top: -7px; right: 24px;
  width: 56px; height: 15px;
  background: rgba(242, 239, 232, 0.16);
  transform: rotate(-4deg); pointer-events: none;
}
.tf-map-fig { border-radius: 3px; overflow: hidden; margin: 0.2rem 0 0.55rem; display: block; }
.tf-map-fig svg { display: block; width: 100%; height: auto; }

/* ── armed mode: desk scene, absolute sheets, closed cover ─── */
html.tf-armed .tf-desk-inner { min-height: 700px; }
html.tf-armed .tf-folder {
  position: absolute; left: 50%; top: 64px;
  width: min(560px, 84%);
  margin: 0;
  transform: translateX(-50%);
  z-index: 3;
}
html.tf-armed .tf-folder-back { box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55); }
html.tf-armed .tf-cover { min-height: 210px; }
html.tf-armed .tf-sheets {
  display: block;
  position: absolute; inset: 0; z-index: 4;
  pointer-events: none;           /* the layer never blocks the cover… */
}
html.tf-armed .tf-sheet { pointer-events: auto; }  /* …the sheets do */
html.tf-armed .tf-sheet {
  position: absolute; left: 50%; top: 55%;
  width: min(320px, 42%);
  transform: translate(-50%, -50%);
  opacity: 0;                    /* GSAP fans them in */
  cursor: grab; touch-action: none; will-change: transform;
}
html.tf-armed .tf-sheet:active { cursor: grabbing; }

/* once the cover is opened by JS it stops catching the pointer */
html.tf-armed .tf-folder.is-open .tf-cover { pointer-events: none; }

/* ── demoted below-desk zone: bezel cards + mono kickers ─────
   (.tf-below rides on .town-page, which already owns the page
   grid, max-width and padding — only surface styling here.) */
.tf-below { padding-top: 1.4rem; }
.tf-below-kicker {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(242, 239, 232, 0.55);
  margin: 0 0 1rem;
  display: flex; align-items: center; gap: 0.8rem;
}
.tf-below-kicker::after {
  content: ""; flex: 1; height: 1px;
  background: rgba(242, 239, 232, 0.10);
}
.tf-below .town-card-mag {
  border: 1px solid rgba(242, 239, 232, 0.10);
  border-radius: 12px;
  background: #0e3034;
  box-shadow: inset 0 1px 0 rgba(242, 239, 232, 0.07);
}
.tf-below .town-briefing {
  border: 1px solid rgba(242, 239, 232, 0.10);
  border-radius: 12px;
  background: #0a2529;
  box-shadow: inset 0 1px 0 rgba(242, 239, 232, 0.07);
}

/* ── mobile ≤640px: 1-col stack, tap-to-front only ─────────── */
@media (max-width: 640px) {
  .tf-scene { padding-left: 0.7rem; padding-right: 0.7rem; }
  .tf-desk { padding: 7px; }
  .tf-desk-inner { padding: 1.1rem 0.8rem 1.2rem; }
  .tf-sheets { grid-template-columns: 1fr; gap: 0.95rem; }
  .tf-folder { margin-top: 34px; margin-bottom: 1.25rem; }
}

/* ── motion hygiene ─────────────────────────────────────────── */
/* RM media block removed — owner decision 2026-07-16 */


/* ── post-verify fixes 2026-07-15 ─────────────────────────────── */
/* sheets never outgrow the desk */
.tf-sheet { max-height: min(60vh, 520px); overflow: hidden auto; }
/* sparse towns (≤2 sheets): compact desk, no cavernous void */
.tf-desk:has(li.tf-sheet:last-child:nth-child(-n+2)) { min-height: 400px; }
