/* F2 visual refresh. CSS only. Loads last (after tokens.css, style.css, f1.css, p3.css).
   Everything is inside @media screen so that print keeps the current F1 layout:
   no fluid width, no watermark and no illustrated headers on paper. */
@media screen {

  /* ---------- 1. Fluid width ---------- */
  :root {
    --f2-gutter: clamp(16px, 1.6vw, 24px);
    --f2-line: #E6DDC8;          /* soft warm border */
    --f2-row: #ECE5D3;           /* row separator */
    --f2-cream: #FFFDF7;
    --f2-pad-y: 14px;
    --f2-pad-x: 16px;
    --f2-radius: 12px;
    /* percentage, not 100vw: resolves against the containing block, so the scrollbar is excluded */
    --wrap: calc(100% - (2 * var(--f2-gutter)));
  }
  header.top, .provenance, main { width: auto; max-width: none; margin-left: var(--f2-gutter); margin-right: var(--f2-gutter); }
  .note-body, .report-preview, main > p { max-width: 80ch; }

  /* ---------- 2. Nav: laptop row raised from 1679px to 1799px so links never run under the utilities ---------- */
  @media (max-width: 1799px) {
    header.top { grid-template-rows: auto auto; }
    .nav-util { grid-area: 1 / 1 / 2 / 3; justify-self: end; height: 36px; padding: 0 0 4px; color: var(--c-text-primary); }
    .nav-util .nav-search .icon { color: var(--c-text-secondary); }
    .nav-user { display: flex; gap: 4px; align-items: baseline; }
    .nav-user span { display: inline; opacity: 1; color: var(--c-text-secondary); }
    header.top .band { grid-area: 2 / 1 / 3 / 3; }
  }
  header.top nav { flex-wrap: nowrap; }
  header.top nav a.on { box-shadow: inset 0 -1px 0 rgba(23,56,36,.18); }
  header.top nav a.on .count { background: #FFF6DC; color: var(--c-forest-900); }

  /* ---------- 6. Watermark: decorative, top right of the open canvas beside the page heading ---------- */
  @media (min-width: 1100px) {
    main { background-image: url(backgrounds/grain-watermark.svg); background-repeat: no-repeat;
      background-position: right 4px top 2px; background-size: 260px 260px; }
  }

  /* ---------- 3. Hierarchy ---------- */
  h1 { font-size: 26px; font-weight: 700; line-height: 1.2; color: var(--c-forest-900); gap: 10px; }
  h1 .icon { width: 26px; height: 26px; color: var(--c-forest-700); }
  .sub { font-size: 13.5px; color: var(--c-text-primary); }

  .panel { background: var(--c-surface); border: 1px solid var(--f2-line); border-radius: var(--f2-radius);
    box-shadow: 0 1px 2px rgba(74,58,20,.05), 0 6px 18px rgba(74,58,20,.07); }
  .panel > h2 { font-size: 17.5px; font-weight: 700; line-height: 1.25; color: var(--c-forest-900); gap: 9px; }
  .panel > h2 .icon { width: 23px; height: 23px; color: var(--c-forest-700); }
  .count { background: var(--c-gold-300); color: var(--c-forest-900); font-weight: 700; font-size: 12px; line-height: 1.6;
    padding: 0 8px; border-radius: 999px; }
  a.more { font-size: 13px; font-weight: 700; color: var(--c-forest-700); }
  .card-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--f2-row); }

  .wb-grid { gap: 14px; margin-bottom: 14px; }
  .wb-grid .panel { padding: var(--f2-pad-y) var(--f2-pad-x); }
  .wb-grid .panel > h2 { margin-bottom: 10px; }

  /* Rows and tables: clearer separation, warm lines */
  th, td { border-color: var(--f2-row); }
  .wb-grid th { background: transparent; border-bottom: 1px solid var(--f2-line); font-weight: 600; }
  .wb-grid th, .wb-grid td { padding: 7px 6px; }
  .wb-grid table { font-size: 13px; background: transparent; }
  .table-wrap { border-color: var(--f2-line); border-radius: var(--f2-radius); }
  .fu-list li { padding: 7px 0; border-bottom: 1px solid var(--f2-row); font-size: 13px; }
  .fu-list li:last-child { border-bottom: 0; }
  button.chk { background: #fff; border-color: #CFC6AF; color: var(--c-forest-700); }
  tr.pos-note td { font-size: 12.25px; padding-bottom: 8px; }
  .wb-conversations h3 { font-size: 13px; font-weight: 700; color: var(--c-forest-700); }
  .wb-conversations li { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--f2-row); }
  .wb-conversations li:last-child { border-bottom: 0; }
  .mk-list li { padding: 7px 0; border-bottom: 1px solid var(--f2-row); }
  .mk-list li:last-child { border-bottom: 0; }

  /* Quote comparison: stop the buyer column wrapping word by word */
  .wb-quotes td { overflow-wrap: normal; word-break: normal; vertical-align: top; }
  .wb-quotes td:nth-child(2) { min-width: 12em; }
  .wb-quotes td:first-child { white-space: nowrap; }

  /* ---------- 4. Illustrated headers (market, quotes, ribbon) ---------- */
  .wb-market.wb-market, .wb-quotes.wb-quotes, section.wb-strip {
    padding: var(--f2-pad-y) var(--f2-pad-x) !important; border: 1px solid var(--f2-line); border-radius: var(--f2-radius); }
  .wb-market > h2, .wb-quotes > h2, .wb-strip > h2 {
    display: flex; align-items: center; gap: 9px; min-height: 46px;
    margin: calc(-1 * var(--f2-pad-y)) calc(-1 * var(--f2-pad-x)) 12px !important;
    padding: 9px var(--f2-pad-x);
    border-radius: calc(var(--f2-radius) - 1px) calc(var(--f2-radius) - 1px) 0 0;
    font-size: 17.5px; font-weight: 700; line-height: 1.25;
    color: var(--f2-cream); text-shadow: 0 1px 2px rgba(10,28,18,.45);
    background-color: var(--c-forest-800);
    background-image: linear-gradient(90deg, rgba(23,56,36,.98) 0%, rgba(27,60,40,.95) 55%, rgba(27,60,40,.66) 82%, rgba(27,60,40,.34) 100%),
      url(backgrounds/wheat-nav-backdrop.jpg);
    background-position: center, right center; background-size: cover; background-repeat: no-repeat; }
  .wb-strip > h2 { background-size: auto, auto 260%; }
  .wb-market > h2 .icon, .wb-quotes > h2 .icon, .wb-strip > h2 .icon { width: 23px; height: 23px; flex: none; color: var(--c-gold-300); }
  .wb-market > h2 .count, .wb-quotes > h2 .count, .wb-strip > h2 .count { background: var(--c-gold-300); color: var(--c-forest-900); text-shadow: none; }
  .wb-market > h2 a, .wb-quotes > h2 a, .wb-strip > h2 a { color: inherit; }
  .wb-market > h2 :focus-visible, .wb-quotes > h2 :focus-visible, .wb-strip > h2 :focus-visible { outline: 3px solid var(--f2-cream); outline-offset: 2px; }

  /* ---------- 5. Commodity icons ---------- */
  .crop { gap: 7px; }
  .crop img { width: 22px; height: 22px; flex: none; }
  .wb-crop .crop img, .wb-quotes .crop img { width: 26px; height: 26px; }
  .wb-crop .crop, .wb-quotes .crop { gap: 9px; }
  .wb-crop .crop { font-weight: 700; color: var(--c-forest-900); }
  .wb-crop .crop .small, .wb-crop .crop .muted { font-weight: 400; color: var(--c-text-secondary); }
  .wb-quotes .crop { font-weight: 600; }
  .directory .crop img { width: 20px; height: 20px; }   /* fits the fixed 22px cells without clipping */

  /* ---------- 7. Intelligence ribbon ---------- */
  section.wb-strip { background: var(--c-surface); box-shadow: 0 1px 2px rgba(74,58,20,.05), 0 6px 18px rgba(74,58,20,.07); margin-bottom: 14px; }
  ul.strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
  li.strip-item { min-width: 0; margin: 0; padding: 12px 14px; background: #fff; border: 1px solid var(--f2-line); border-radius: 10px;
    box-shadow: 0 1px 2px rgba(74,58,20,.04); }
  li.strip-item .icon { width: 24px; height: 24px; color: var(--c-forest-700); }
  li.strip-item .l { font-size: 13px; font-weight: 700; color: var(--c-forest-900); }
  li.strip-item .v { font-size: 20px; font-weight: 600; line-height: 1.3; }
  /* Unavailable never reads as a value: smaller, caution colour, dashed warning tile */
  li.strip-item .v.unavailable, li.strip-item .unavailable .v { font-size: 15px; color: var(--c-caution); }
  li.strip-item.unavailable { background: var(--c-surface-warning); border: 1.5px dashed #D9B766; color: var(--c-caution); box-shadow: none; }

  /* ---------- 8. Evidence labels: soft pills, not buttons ---------- */
  .ev { display: inline-block; padding: 2px 10px; border: 1px solid #DCD5C2; border-radius: 999px; background: #EFEADC; color: #3F4A3F;
    font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; box-shadow: none; cursor: default; text-decoration: none; }
  .ev-quote { background: #E3EFE2; border-color: #C8DCC7; color: var(--c-forest-900); }
  .ev-hist { background: #EFEADC; border-color: #DCD5C2; color: #3F4A3F; }
  .ev-none { background: #FBEBC0; border-color: #EAD48E; color: #6F4400; }

  /* ---------- Live panels (P4 contract): states stay distinct ---------- */
  section.live-panel.live-stale { border-left: 4px solid var(--c-caution); }
  section.live-panel.live-unavailable { background: var(--c-surface-warning); border: 1.5px dashed #D9B766; box-shadow: none; }
  .live-reason { color: var(--c-caution); font-weight: 600; font-size: 12.75px; }
  .wb-pins .unavailable { border-color: #D5CCB6; border-radius: 10px; }

  @media (max-width: 900px) {
    .wb-quotes td:nth-child(2) { min-width: 8em; }
    ul.strip { grid-template-columns: 1fr; }
  }
}
/* Nothing left unfinished. Not verified in a browser (budget: one write, no re-read). */

/* ---------- Opus integration (15 Nov 2026), from measured renders at 1366-2560 px ---------- */
@media screen {
  /* Quote comparison: the 12em buyer minimum clipped the table inside its card (204 px at 1366, also at 1800).
     Let the price wrap and give the buyer room only where the card is wide enough. */
  .wb-quotes td:nth-child(2) { min-width: 0; }
  .wb-quotes td.n { white-space: normal; }
  @media (min-width: 1900px) { .wb-quotes td:nth-child(2) { min-width: 9em; } }
  /* Help sits on the dark band from 1800 px: forest link colour was unreadable there */
  @media (min-width: 1800px) { .nav-util .nav-help { color: var(--f2-cream); } }
  /* Same band: .nav-util is not inside .band, so its focus ring stayed blue on forest (about 2:1). Cream, as on the band. */
  @media (min-width: 1800px) { .nav-util :focus-visible { outline-color: var(--f2-cream); } }
  /* Ribbon: "No verified data" is a .muted span, not .unavailable; keep it from reading as a value (hard rule 2) */
  li.strip-item .v .muted { font-size: 15px; font-weight: 600; color: var(--c-text-secondary); }
  /* .report-preview wraps the report tables (the brief wrongly listed it as prose): cap only its paragraphs */
  .report-preview { max-width: none; }
  .report-preview p { max-width: 80ch; }
  /* ribbon tiles: style.css `ul.plain li` out-ranked the tile padding, leaving text against the border */
  ul.plain.strip li.strip-item { padding: 12px 14px; }
}

/* ---------- A1 Historical review period bar (Opus, 15 Nov 2026) ---------- */
@media screen {
  .period-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
    margin: 8px var(--f2-gutter, 24px) 0; padding: 8px 14px; border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-surface); font-size: 13px; color: var(--c-text-primary); }
  .period-bar.historical { border-left: 4px solid var(--c-gold-500); background: var(--c-surface-alt); }
  .period-bar.current { border-left: 4px solid var(--c-forest-700); }
  .period-bar .period-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
  .period-bar .period-text strong { color: var(--c-forest-800); font-size: 14px; }
  .period-bar .period-dates, .period-bar .period-note { color: var(--c-text-secondary); }
  .period-bar .period-form { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin: 0; }
  .period-bar .period-form label { font-weight: 600; white-space: nowrap; }
  .period-bar .period-form select { max-width: 28em; height: 32px; }
}
@media print { .period-bar .period-form { display: none; } }

/* ---------- A3 findings and report history (Opus, 15 Nov 2026) ---------- */
@media screen {
  .report-history svg.chart { width: 100%; max-width: 520px; height: auto; display: block; }
  .finding .finding-answer { max-width: 110ch; }
  .finding form.inline { flex-wrap: nowrap; gap: 6px; }
}

/* ---------- A4 visual close-out (Opus, 15 Nov 2026) ---------- */
@media screen {
  /* F2 defect #9: follow-up rows as a compact grid (done | title and details | assign), no wrapping under each title */
  ul.task-rows > li.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: start;
    padding: 8px 0; border-bottom: 1px solid var(--f2-row, #ECE5D3); }
  ul.task-rows > li.task-row:last-child { border-bottom: 0; }
  li.task-row form { margin: 0; }
  li.task-row .task-title { font-weight: 600; overflow-wrap: anywhere; }
  li.task-row .task-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; margin-top: 2px; }
  li.task-row .task-assign { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
  li.task-row .task-assign select { max-width: 9.5em; height: 30px; font-size: 13px; }
  /* ribbon tiles: icon before the label (crop icon for historical prices) */
  li.strip-item .l { display: flex; align-items: center; gap: 8px; }
  li.strip-item .l .crop img { width: 24px; height: 24px; }
}
@media screen and (max-width: 1500px) {
  /* narrow cards: the assign control moves under the title instead of squeezing it */
  .panel ul.task-rows > li.task-row { grid-template-columns: auto minmax(0, 1fr); }
  .panel li.task-row .task-assign { grid-column: 2; }
}
