/*
 * Reading Leaves — Visual Convergence pass (client spec, 2026-10-03:
 * "READING LEAVES — VISUAL CONVERGENCE PASS"). See js/leaves.js's header
 * for exactly what's frozen vs. rewritten. Visual language: warm paper,
 * translucent layered pigment, fine calligraphic currents that travel
 * through formations, large porous territories, no glow/node/graph
 * aesthetics, labels mostly hover-revealed rather than permanent.
 */


.readby-row { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.readby-btn {
  all: unset; cursor: pointer; padding: 7px 16px; border-radius: 16px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--brown-field); color: var(--ink-soft);
}
.readby-btn.active { background: var(--ink-2); color: var(--on-dark); border-color: var(--ink-2); }

/* "This reading" (spec §13) - same frozen summary content as before,
   made visually quiet/subordinate to the artwork: one inline line, not a
   boxed panel. */
.this-reading-quiet { margin-top: 14px; font-size: 13px; color: var(--ink-mid); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.trq-strongest { font-style: italic; color: var(--rust); font-weight: 600; }
.trq-meta { color: var(--ink-mid); }

.find-row-wrap { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.surprise-btn { all: unset; cursor: pointer; padding: 5px 14px; border-radius: 14px; font-size: 12px; font-weight: 700; color: var(--on-dark); background: var(--rust); }
.surprise-btn:hover { background: var(--ochre); color: var(--ink-2); }
.save-link-btn { all: unset; cursor: pointer; padding: 5px 14px; border-radius: 14px; font-size: 12px; font-weight: 600; color: var(--ink-soft); border: 1px solid var(--brown-field); margin-left: 8px; }
.save-link-btn:hover { background: var(--cream-2); }

/* Search as evidence finder (spec §8) - the "Read around X" contextual
   action, shown only when the query has no match in the current
   reading. */
.search-read-around { margin-top: 8px; font-size: 13px; }
.search-read-around a { color: var(--rust); font-weight: 600; text-decoration: none; }
.search-read-around a:hover { text-decoration: underline; }
.search-no-match { color: var(--ink-mid); font-style: italic; }

/* Zero-filter-match quiet state (spec §12) - replaces the SVG entirely,
   not an overlay on an empty field. */
.field-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100%; color: var(--ink-mid); font-style: italic; }
.field-empty-state button { all: unset; cursor: pointer; padding: 6px 16px; border-radius: 14px; font-size: 12.5px; font-weight: 600; font-style: normal; color: var(--on-dark); background: var(--rust); }
.devview-link { font-size: 11px; color: var(--ink-mid); text-decoration: underline; text-decoration-style: dotted; margin-left: 4px; }
/* This reading's actual evidence span, overlaid on the shared timeline
   slider (client request, 2026-10-04) - sits along the bottom edge of
   the track so it never competes visually with the real filter handles
   above it. Decorative only (pointer-events:none); the draggable inputs
   remain the only interactive part of the timeline. */
.reading-range-band { position: absolute; bottom: 2px; height: 5px; border-radius: 3px; background: var(--rust); opacity: .55; pointer-events: none; }

/* "Reading by X" transient cue (Production Handoff spec §6). */
.readby-cue {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 7; pointer-events: none;
  background: var(--ink-2); color: var(--on-dark); font-size: 12.5px; font-weight: 600; font-style: italic;
  padding: 6px 16px; border-radius: 14px; opacity: 0; transition: opacity 450ms ease;
}
/* Escape hatch for ?devview=naked, which otherwise hides this whole page
   (client-reported, 2026-10-04: no way back without hand-editing the
   URL) - deliberately outside .find-row-wrap so devview-naked's
   display:none rule below doesn't catch it. */
.devview-escape { position: fixed; top: 10px; left: 10px; z-index: 20; font-size: 11px; color: var(--ink-mid); background: var(--cream-2); padding: 4px 9px; border-radius: 10px; text-decoration: none; opacity: .75; }
.devview-escape:hover { opacity: 1; }

.find-list { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.find-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; padding: 10px 0; border-top: 1px solid #4A3A28; }
.find-row-label { font-size: 14px; color: var(--on-dark); }
.find-row-metric { font-size: 12px; color: var(--on-dark-2); white-space: nowrap; margin-left: 12px; }

.leaf-why-list { margin: 0; padding-left: 18px; }
.leaf-why-list li { margin-top: 3px; font-style: italic; }

.leaf-row-link, .leaf-source-link, .leaf-event-link { cursor: pointer; }
.leaf-source-link { text-decoration: underline; text-decoration-color: rgba(238,199,122,.5); }
.leaf-row-link:hover, .leaf-source-link:hover { color: var(--gold-eyebrow); }
.leaf-event-link:hover { opacity: .85; }
.leaf-row-attrs, .leaf-source-attrs { width: 100%; margin-top: 8px; padding: 10px 12px; background: #2A1F15; border-radius: 5px; font-size: 12.5px; }
.leaf-attrs-title { font-weight: 700; color: var(--on-dark); margin-bottom: 4px; }
.leaf-attrs-line { color: var(--on-dark-2); }
.leaf-attrs-link { display: inline-block; margin-top: 6px; color: var(--gold-eyebrow); font-weight: 600; font-size: 12px; }
.leaf-row-attrs .entry-links { margin-top: 0; }
.leaf-row-attrs .entry-links a { display: block; margin: 3px 0; }

.field-wrap { position: relative; margin-top: 18px; }

/* Warm paper base, extremely restrained grain (spec §13) - no glossy
   gradients, no glow halos (the SVG feTurbulence grain rect sits once
   behind the whole field, not per-leaf). */
.field-panel {
  position: relative; height: 720px; border-radius: 4px; overflow: hidden; cursor: grab;
  background: radial-gradient(ellipse at 50% 45%, var(--paper) 0%, var(--cream-2) 100%);
  box-shadow: inset 0 0 50px rgba(60, 44, 30, .05);
}
.field-panel.dragging { cursor: grabbing; }
.field-svg { display: block; }
/* devview=naked (spec §19 test A/acceptance screenshots) - paper+leaves+
   currents only: no sidebar/nav/controls/chrome, just the field. */
.field-wrap-naked .field-panel { height: 94vh; border-radius: 0; }
body.devview-naked .sidebar, body.devview-naked .tool-topbar,
body.devview-naked .tool-title, body.devview-naked .tool-desc,
body.devview-naked .controls, body.devview-naked .readby-row, body.devview-naked .this-reading-quiet,
body.devview-naked .find-row-wrap { display: none !important; }
body.devview-naked .shell { display: block; }
body.devview-naked .main { max-width: none; padding: 0; margin: 0; }
body.devview-naked .field-wrap { margin-top: 0; }

.field-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.field-spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--brown-field); border-top-color: var(--rust); animation: field-spin 800ms linear infinite; opacity: .5; }
@keyframes field-spin { to { transform: rotate(360deg); } }

.leaf-mark { pointer-events: auto; cursor: pointer; transition: opacity 300ms; }
.leaf-mark.dim { opacity: .1 !important; }
/* Search evidence-finder highlight (spec §8) - "highlight/locate", not a
   new selection state, so it's deliberately lighter than the .dim
   contrast used for formation/current selection dimming. */
.leaf-mark.search-match { opacity: 1 !important; }
.leaf-mark.search-match path:first-child { stroke: var(--rust); stroke-width: 1.4px; }
/* Retained significant exceptions during a filter (spec §7) - "treat it
   visually as intentional, not grey debris." A thin dotted ring reads as
   deliberately kept, distinct from an ordinary fringe/anomaly leaf. */
.leaf-mark.significant-exception path:first-child { stroke: var(--ochre); stroke-width: 1px; stroke-dasharray: 2 1.5; }

/* Currents (spec §10) - hairline calligraphic traces, not graph edges.
   Width is set per-element in JS (0.35-1.8px per the spec's own
   guidance); this just fixes the visual TREATMENT (round caps, behind
   leaves, no fill). */
.current { fill: none; stroke-linecap: round; }
.current-halo { stroke: var(--ink-mid); stroke-width: .5; }

.pattern-hit { fill: transparent; cursor: pointer; pointer-events: auto; }

/* Keyboard focus (spec §15: "elegant focus state") - SVG elements have
   no default focus ring worth keeping, so give role="button" elements
   an explicit one. */
.leaf-mark:focus-visible, .pattern-hit:focus-visible, .current-hit:focus-visible {
  outline: 2px solid var(--rust); outline-offset: 2px;
}
.leaf-mark:focus:not(:focus-visible), .pattern-hit:focus:not(:focus-visible), .current-hit:focus:not(:focus-visible) { outline: none; }

/* Screen-reader-only summary (spec §15: an accessible summary BEFORE the
   ~115 individual leaves, not forcing a screen-reader user through all
   of them first). Visually hidden, still in reading order. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.field-svg.lod-aggregate .leaf-layer { display: none; }

.field-toolbar { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; z-index: 6; }
.field-toolbar button { all: unset; cursor: pointer; width: 30px; height: 30px; border-radius: 50%; background: var(--ink-2); color: var(--on-dark); font-size: 16px; display: flex; align-items: center; justify-content: center; }
.field-toolbar button:hover { background: var(--rust); }
.field-toolbar .disturb-btn { width: auto; border-radius: 16px; padding: 0 14px; font-size: 12.5px; font-weight: 600; }

/* Detail card (spec §15) - the mockup's own white rounded card, not the
   dark hover-cards V1/V2 used elsewhere on the site; Reading Leaves gets
   its own close match to the approved artwork here specifically. */
.hover-card {
  position: absolute; z-index: 8; pointer-events: none; display: none; max-width: 230px;
  background: #FBF8F2; color: var(--ink-2); border-radius: 8px; padding: 12px 14px; font-size: 12.5px;
  box-shadow: 0 10px 26px rgba(40,30,20,.18); border: 1px solid rgba(60,44,30,.08);
}
.hover-card.show { display: block; }
.hover-card .hc-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; font-style: italic; color: var(--ink); }
.hover-card .hc-count { color: var(--ink-mid); margin-bottom: 4px; }
.hover-card .hc-stats { color: var(--ink-mid); font-size: 11.5px; opacity: .85; }

/* Formation labels (spec §12 - "labels retreat") - hidden at rest except
   the primary (and sometimes a strong secondary); everything else is
   revealed on hover via wireFieldInteraction, with its own transition so
   it doesn't just snap on/off. */
.formation-label { font-size: 13px; font-weight: 500; font-style: italic; fill: var(--ink-soft); pointer-events: none; transition: opacity 250ms ease; }
.formation-label-primary { font-size: 15px; font-weight: 600; fill: var(--ink); }

.leaf-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.leaf-detail-grid > div { background: #3C2C1E; border-radius: 5px; padding: 8px 10px; cursor: pointer; transition: background 150ms; }
.leaf-detail-grid > div:hover { background: var(--rust); }
.leaf-detail-grid strong { display: block; font-size: 20px; color: var(--on-dark); }
.leaf-detail-grid span { font-size: 11px; color: var(--on-dark-2); text-transform: uppercase; letter-spacing: .04em; }
.leaf-sample { margin-top: 14px; }
.leaf-sample .meta { margin-top: 3px; font-size: 11.5px; }
.leaf-detail-viewall { all: unset; cursor: pointer; display: block; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--gold-eyebrow); }
.leaf-detail-viewall:hover { color: var(--on-dark); }

/* Restrained ambient motion (spec §19) - scoped to each leaf's own inner
   <path> opacity only, never the outer <g>'s settle-tween transform or a
   current's own affinity-scaled opacity (a bare CSS `animation` on
   either of those would fight the inline values leaves.js sets
   continuously). Currents deliberately don't breathe - "nearly invisible
   when not watched closely" applies to leaves, not to a current's
   evidentiary strength. */
.leaf-mark path:first-child { animation: leaf-breathe 9s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.leaf-mark:nth-child(3n) path:first-child { animation-duration: 12s; }
.leaf-mark:nth-child(5n) path:first-child { animation-duration: 14s; }
@keyframes leaf-breathe { from { opacity: .82; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .leaf-mark path:first-child { animation: none !important; }
}

/* Mouse-proximity "rustle" (client request, 2026-10-04: leaves should
   very slightly flutter as the cursor passes near, like a pile catching
   a gentle wind). leaves.js sets/clears this inner <g>'s CSS transform
   per-frame on mousemove; the easing back to rest is this transition,
   not JS - keeps the effect cheap even across ~100-300 leaves. */
.leaf-rustle-inner { transition: transform 420ms cubic-bezier(.22,1,.36,1); transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: reduce) {
  .leaf-rustle-inner { transition: none !important; }
}

/* Debug mode (Production Handoff spec §17, ?debug=1 only). */
.debug-panel { margin-top: 18px; background: #1E1610; border-radius: 6px; padding: 12px 14px; max-height: 320px; overflow: auto; }
.debug-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.debug-panel-head strong { color: var(--on-dark); font-size: 13px; }
.debug-panel-head button { all: unset; cursor: pointer; padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--rust); color: var(--on-dark); }
.debug-panel pre { margin: 0; color: var(--on-dark-2); font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
