/* EOD report demo — styled in the Farmhand "Dispatch" language (apps/task-tool-web/src/design):
   objects are physical (paper tags, 2px ink borders, hard offset shadows, near-sharp corners);
   the environment is the plaster wall. Tokens mirror design/tokens.css.
   Chart DATA colors follow the validated dataviz reference palette (light instance),
   re-validated against the paper surface; chart chrome reads the app tokens. */

:root {
  color-scheme: light;
  /* surfaces */
  --board:        #EDE8DC;
  --board-deep:   #E2DCCB;
  --board-soft:   #FBF8F0;
  --tag:          #F7F1E1;
  --tag-sunk:     #DDD6C3;
  --line:         #D7D0BD;
  --line-strong:  #B9B19B;
  /* ink */
  --ink:          #211D15;
  --ink-soft:     #5C564A;
  --ink-faint:    #97907D;
  --ink-inv:      #F7F1E1;
  /* accent */
  --marigold:      #E8A22B;
  --marigold-deep: #9A6A0F;
  --marigold-wash: #F6E7C6;
  /* state (from the task board: blocked is safety-orange, red reserved for failures) */
  --st-running:      #2E7D46;
  --st-running-wash: #E2EFE5;
  --st-blocked:      #D2571E;
  --st-blocked-ink:  #A8420F;
  --st-blocked-wash: #F9E4D8;
  --st-proposed:     #3A5380;
  --st-proposed-wash:#E3E9F1;
  --failure:         #B3261E;
  /* severity text colors consumed by app.js inline styles */
  --status-critical: #A8420F;
  --status-warning:  #9A6A0F;
  --status-good:     #2E7D46;
  --delta-good:      #2E7D46;
  /* chart data colors — validated light pair on this surface */
  --series-1: #2a78d6;
  --div-pos:  #2a78d6;
  --div-neg:  #e34948;
  /* type */
  --font-display: "Archivo", system-ui, sans-serif;
  --font-body:    "Archivo", system-ui, sans-serif;
  --font-serif:   "Instrument Serif", Georgia, serif;
  --font-mono:    "Spline Sans Mono", ui-monospace, monospace;
  --track-caps:   0.08em;
  /* shape + shadow */
  --radius:       3px;
  --radius-card:  10px;
  --radius-pill:  999px;
  --shadow-hard:  6px 6px 0 rgba(33, 29, 21, 0.15);
  --shadow-mid:   3px 3px 0 rgba(33, 29, 21, 0.18);
  --shadow-stamp: 2px 2px 0 rgba(33, 29, 21, 0.18);
  --shadow-press: 1px 1px 0 rgba(33, 29, 21, 0.22);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  /* the plaster wall — top light + two faint grain passes, as in base.css */
  background:
    radial-gradient(1200px 480px at 50% -120px, rgba(255, 255, 255, 0.5), transparent 70%),
    repeating-linear-gradient(105deg, rgba(33, 29, 21, 0.014) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(15deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 5px),
    var(--board);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--marigold); color: var(--ink); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--board); }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid var(--board);
  border-radius: var(--radius-pill);
}
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--marigold-deep); outline-offset: 2px; }

/* caps signage voice */
.caps, h2, .stat .l, .subhead, .chip, .rb-label {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
}

#app { max-width: 1480px; margin: 0 auto; padding: 24px 28px 90px; }

/* ---------- masthead ---------- */
#masthead {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; padding: 4px 2px 22px;
}
.brand { font-family: var(--font-display); font-stretch: 125%; font-weight: 800; font-size: 12px; letter-spacing: 0.22em; color: var(--marigold-deep); }
.brand span { color: var(--ink-faint); font-weight: 600; }
#masthead h1 {
  margin: 8px 0 6px; font-family: var(--font-serif); font-weight: 400;
  font-size: 38px; line-height: 1.05; letter-spacing: 0;
}
.meta { color: var(--ink-soft); font-size: 13px; }
.meta .site-chip {
  display: inline-block; margin: 6px 8px 0 0; padding: 3px 12px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--tag); box-shadow: var(--shadow-press);
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink);
}
.report-badge {
  text-align: right; background: var(--tag);
  border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-mid); padding: 12px 18px;
}
.rb-label { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.rb-date { font-family: var(--font-serif); font-size: 22px; margin-top: 2px; }
.rb-gen { font-size: 12px; color: var(--ink-faint); }

/* ---------- layout ---------- */
#layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 26px; align-items: start; }
@media (max-width: 1080px) { #layout { grid-template-columns: 1fr; } #chat { position: static; height: 560px; } }

h2 {
  font-size: 13px; font-weight: 800; color: var(--ink-soft);
  margin: 30px 0 14px; border-bottom: 2px solid var(--line-strong); padding-bottom: 6px;
}
#attention h2 { margin-top: 0; }
#sections > h2:first-child { margin-top: 0; }

.card {
  background: var(--board-soft); border: 2px solid var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow-hard);
  padding: 18px 20px; margin-bottom: 18px;
}

/* ---------- attention items ---------- */
.att .att-main { min-width: 0; }
.att-top { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 8px; }
.att-title { font-family: var(--font-serif); font-size: 23px; line-height: 1.15; margin: 2px 0 8px; }
.att-summary { color: var(--ink-soft); }
.att-rec {
  margin-top: 10px; padding: 10px 13px; background: var(--marigold-wash);
  border-left: 4px solid var(--marigold); border-radius: 0 var(--radius) var(--radius) 0;
}
.att-rec b { color: var(--marigold-deep); font-family: var(--font-display); font-stretch: 125%; text-transform: uppercase; letter-spacing: var(--track-caps); font-size: 11.5px; }
.att-value { margin-top: 8px; font-size: 12.5px; color: var(--ink-faint); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800;
  padding: 3px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft); background: var(--tag); white-space: nowrap;
}
.chip.src { font-weight: 600; color: var(--ink-faint); }
.sev-high   { color: var(--st-blocked-ink); background: var(--st-blocked-wash); border-color: var(--st-blocked); }
.sev-medium { color: var(--marigold-deep); background: var(--marigold-wash); border-color: var(--marigold); }
.sev-low, .sev-info { color: var(--ink-soft); }
.sev-good   { color: var(--st-running); background: var(--st-running-wash); border-color: var(--st-running); }

/* ---------- report sections ---------- */
.section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 24px; margin: 4px 0 10px; }
.stat { min-width: 100px; }
.stat .v { font-family: var(--font-mono); font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.stat .v small { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.stat .l { font-size: 10.5px; font-weight: 800; color: var(--ink-faint); margin-top: 2px; }
.delta-up { color: var(--delta-good); font-size: 12px; font-weight: 700; font-family: var(--font-body); text-transform: none; letter-spacing: 0; }
.delta-down { color: var(--st-blocked-ink); font-size: 12px; font-weight: 700; font-family: var(--font-body); text-transform: none; letter-spacing: 0; }
.delta-flat { color: var(--ink-faint); font-size: 12px; }

.subhead { font-size: 11px; font-weight: 800; color: var(--ink-soft); margin: 16px 0 7px; }
.note { font-size: 12.5px; color: var(--ink-soft); margin-top: 9px; }

ul.plain { margin: 6px 0 0; padding-left: 18px; color: var(--ink-soft); list-style: square; }
ul.plain li { margin-bottom: 4px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th {
  text-align: left; color: var(--ink-faint); font-weight: 600; padding: 3px 8px 3px 0;
  border-bottom: 2px solid var(--line-strong);
  font-family: var(--font-display); font-stretch: 125%; text-transform: uppercase;
  letter-spacing: var(--track-caps); font-size: 10px;
}
table.mini td {
  padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line);
  color: var(--ink-soft); font-family: var(--font-mono); font-size: 12px;
}
table.mini td:first-child { color: var(--ink); font-family: var(--font-body); font-size: 12.5px; }

.flagline { display: flex; gap: 9px; margin-bottom: 10px; align-items: baseline; }
.flagline .chip { flex: none; }
.flagline .t { color: var(--ink-soft); }
.flagline .t b { color: var(--ink); }
.flagline .a { color: var(--ink-faint); font-size: 12.5px; }

/* forecast strip */
.fc-strip { display: flex; gap: 10px; }
.fc-day {
  flex: 1; text-align: center; background: var(--tag);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-press); padding: 9px 4px;
}
.fc-day .d { font-size: 11px; color: var(--ink-faint); font-family: var(--font-display); font-stretch: 125%; text-transform: uppercase; letter-spacing: var(--track-caps); }
.fc-day .hi { font-family: var(--font-mono); font-size: 19px; font-weight: 800; margin: 2px 0; }
.fc-day .lo { font-size: 11.5px; color: var(--ink-faint); }
.fc-day .thi { font-size: 10.5px; margin-top: 5px; font-weight: 800; }

/* market tiles */
.mkt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mkt {
  background: var(--tag); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-press); padding: 9px 12px;
}
.mkt .n { font-size: 11px; color: var(--ink-faint); }
.mkt .p { font-family: var(--font-mono); font-size: 15px; font-weight: 800; margin-top: 1px; }

/* ---------- cctv clip wall ---------- */
.cctv-note { margin: 2px 0 14px; font-style: italic; font-family: var(--font-serif); font-size: 15px; color: var(--ink-soft); }
.cctv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.clip-card {
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--tag); box-shadow: var(--shadow-mid);
  display: flex; flex-direction: column; overflow: hidden;
}
.clip-thumb {
  position: relative; height: 150px; flex: none; overflow: hidden;
  /* base night-vision field for glyph fallbacks; photos sit on top of it */
  background:
    radial-gradient(120% 90% at 50% 20%, rgba(247, 241, 225, 0.14), transparent 60%),
    repeating-linear-gradient(0deg, rgba(247, 241, 225, 0.05) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #2e2a20, #211D15 70%);
  border-bottom: 2px solid var(--ink);
  color: var(--ink-inv);
}
.clip-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  /* camera-still grade: desaturate + darken so overlays read on top */
  filter: grayscale(0.55) contrast(1.04) brightness(0.72) sepia(0.12);
}
.clip-scan {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(20, 17, 12, 0.62), transparent 32%),
    linear-gradient(0deg, rgba(20, 17, 12, 0.62), transparent 32%),
    repeating-linear-gradient(0deg, rgba(247, 241, 225, 0.045) 0 1px, transparent 1px 3px);
}
.clip-thumb .corner, .clip-cam, .clip-ts { z-index: 1; }
.clip-thumb .corner { position: absolute; width: 14px; height: 14px; border: 2px solid rgba(247, 241, 225, 0.55); }
.clip-thumb .corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.clip-thumb .corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.clip-thumb .corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.clip-thumb .corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; }
.clip-cam {
  position: absolute; top: 10px; left: 26px; right: 26px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  color: rgba(247, 241, 225, 0.85); text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.clip-glyph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 30px; opacity: 0.5;
}
.clip-ts {
  position: absolute; bottom: 10px; left: 26px; right: 26px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: rgba(247, 241, 225, 0.75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* severity edge bar on the still, like the task board's state edge — layered above the photo */
.clip-thumb::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; z-index: 1;
}
.clip-thumb.sev-bar-high::before   { background: var(--st-blocked); }
.clip-thumb.sev-bar-medium::before { background: var(--marigold); }
.clip-thumb.sev-bar-low::before    { background: var(--line-strong); }
.clip-thumb.sev-bar-info::before   { background: var(--line-strong); }
.clip-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.clip-body .t { color: var(--ink-soft); font-size: 13px; line-height: 1.45; flex: 1; }
.clip-actions { display: flex; align-items: center; gap: 10px; }
.clip-resolved { color: var(--st-running); font-size: 12px; font-weight: 700; }

/* ---------- charts ---------- */
.viz { margin-top: 6px; }
.viz svg { display: block; width: 100%; height: auto; }
.viz text { font-family: var(--font-body); }
.viz .axis-label { fill: var(--ink-faint); font-size: 10.5px; }
.viz .direct-label { fill: var(--ink-soft); font-size: 10.5px; font-weight: 700; font-family: var(--font-mono); }
.viz .gridline { stroke: var(--line); stroke-width: 1; }
.viz .baseline { stroke: var(--line-strong); stroke-width: 1; }

#viz-tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--board-soft); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 6px 10px; font-size: 12px; color: var(--ink);
  box-shadow: var(--shadow-stamp); max-width: 260px;
}
#viz-tooltip .tl { color: var(--ink-faint); font-size: 11px; }

/* ---------- chat ---------- */
#chat {
  position: sticky; top: 16px; height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: var(--board-soft);
  border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  overflow: hidden;
}
.chat-head { padding: 14px 16px 10px; border-bottom: 2px solid var(--line-strong); background: var(--tag); }
.chat-title { font-family: var(--font-serif); font-size: 21px; }
.chat-sub { font-size: 12px; color: var(--ink-faint); }
#chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; }
.msg { margin-bottom: 12px; max-width: 92%; }
.msg.user {
  margin-left: auto; background: var(--marigold-wash);
  border: 1px solid var(--marigold); border-radius: var(--radius);
  padding: 8px 12px; box-shadow: var(--shadow-press);
}
.msg.agent { color: var(--ink-soft); }
.msg.agent p { margin: 0 0 8px; }
.msg.agent ul, .msg.agent ol { margin: 0 0 8px; padding-left: 18px; }
.msg.agent li { margin-bottom: 3px; }
.msg.agent strong { color: var(--ink); }
.msg.agent .cursor { display: inline-block; width: 7px; height: 14px; background: var(--marigold); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

#chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.suggest-chip {
  border: 1px solid var(--line-strong); background: var(--tag); color: var(--ink-soft);
  font: inherit; font-size: 12px; border-radius: var(--radius-pill); padding: 4px 12px; cursor: pointer;
}
.suggest-chip:hover { color: var(--marigold-deep); border-color: var(--marigold-deep); background: var(--marigold-wash); }

#chat-form { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 2px solid var(--line-strong); background: var(--tag); }
#chat-input {
  flex: 1; background: var(--board-soft); border: 2px solid var(--line-strong);
  border-radius: var(--radius); color: var(--ink); font: inherit; padding: 9px 12px; outline: none;
}
#chat-input:focus { border-color: var(--marigold-deep); }
#chat-send {
  width: 42px; border-radius: var(--radius); border: 2px solid var(--ink); cursor: pointer;
  background: var(--marigold); color: var(--ink); font-size: 17px; font-weight: 800;
  box-shadow: var(--shadow-stamp);
}
#chat-send:hover { transform: translate(1px, 1px); box-shadow: var(--shadow-press); }
#chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
