/* ============================================================================
   The FieldServiceOps Gazette — an old-newspaper dashboard.
   Paper and ink, hairline and double rules, columns and figure captions.
   The second ink is the DesignGuide's deep green (#2c5f4e); its live green
   (#22c55e / #7bdc93) is kept for the wire indicator only.
   ========================================================================== */

:root {
  --paper: #f4efe3;
  --paper-2: #ece5d3;      /* boxes, "inset" panels */
  --paper-3: #e2d9c2;      /* deeper shade for stat boxes */
  --ink: #1c1a17;
  --ink-2: #4a463f;        /* secondary text */
  --ink-3: #7a7468;        /* captions, folios */
  --rule: #1c1a17;
  --rule-soft: rgba(28, 26, 23, 0.28);
  --green: #2c5f4e;        /* DesignGuide sidebar green — the second ink */
  --green-ink: #1f4a3c;
  --live: #22c55e;         /* DesignGuide primary */
  --live-soft: #7bdc93;

  --masthead: "UnifrakturCook", "Old English Text MT", serif;
  --display: "Playfair Display", "Times New Roman", serif;
  --body: "Libre Baskerville", Georgia, "Times New Roman", serif;

  --gutter: 28px;
  --col-gap: 24px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  line-height: 1.5;
  background-color: var(--paper);
  /* faint paper grain: two soft radial washes, no images */
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, 0.35), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(120, 95, 50, 0.08), transparent 60%);
  background-attachment: fixed;
  font-feature-settings: "onum" 1, "liga" 1;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--display); line-height: 1.15; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

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

/* ---------------------------------------------------------------------------
   Page frame
   ------------------------------------------------------------------------- */

.sheet {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px var(--gutter) 40px;
}

/* Ears + masthead */
.ears {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 16px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 6px 0;
  font-size: 0.8rem;
  color: var(--ink-2);
}
.ears .ear-right { text-align: right; }
.ears .ear-center { text-align: center; letter-spacing: 0.06em; }

.masthead {
  text-align: center;
  padding: 18px 0 10px;
  border-bottom: 4px double var(--rule);
}
.masthead .title {
  font-family: var(--masthead);
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.masthead .title span { color: var(--green); }
.masthead .motto {
  margin-top: 8px;
  font-family: var(--display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-2);
}

.dateline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.dateline .wire-state { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; }
.wire-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulse 2.4s ease-out infinite;
}
.wire-dot.off { background: #b45309; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Body: index | content | wire */
.broadsheet {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 260px;
  gap: 0 var(--col-gap);
  margin-top: 14px;
}
.broadsheet > * { min-width: 0; }
.index-col { border-right: 1px solid var(--rule-soft); padding-right: var(--col-gap); }
.wire-col { border-left: 1px solid var(--rule-soft); padding-left: var(--col-gap); }

/* Section index (the newspaper's "Inside" box) */
.index-head, .wire-head, .box-head {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  padding: 5px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}
.index-list { list-style: none; margin: 0; padding: 0; }
.index-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px dotted var(--rule-soft);
  color: var(--ink-2);
  font-size: 0.93rem;
}
.index-link .icon { width: 16px; height: 16px; flex: 0 0 auto; color: var(--ink-3); }
.index-link:hover { color: var(--ink); }
.index-link.active { color: var(--green-ink); font-weight: 700; }
.index-link.active .icon { color: var(--green); }
.index-link .pg { margin-left: auto; font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.index-note { margin-top: 14px; font-size: 0.78rem; color: var(--ink-3); font-style: italic; line-height: 1.4; }

.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }

/* ---------------------------------------------------------------------------
   Stories, headlines, figures
   ------------------------------------------------------------------------- */

.story { }
.kicker {
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green-ink);
  margin-bottom: 6px;
}
.headline {
  font-size: clamp(1.7rem, 3.2vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.deck {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-2);
  max-width: 68ch;
  margin-bottom: 14px;
}
.byline {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  padding: 4px 0;
  margin-bottom: 16px;
}
.lede { font-size: 0.98rem; max-width: 70ch; margin-bottom: 18px; }
.lede::first-letter {
  font-family: var(--display);
  font-weight: 900;
  font-size: 3.3em;
  float: left;
  line-height: 0.82;
  padding: 4px 8px 0 0;
  color: var(--green);
}

.section-rule {
  display: flex; align-items: center; gap: 12px;
  margin: 26px 0 12px;
  font-family: var(--display); font-weight: 700; font-size: 0.85rem;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.section-rule::before, .section-rule::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.section-rule::after { border-top-width: 3px; border-top-style: double; }

/* Figure grid: "columns" of the paper */
.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 22px var(--col-gap);
}
.figures.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }

.figure {
  border-top: 3px double var(--rule);
  padding-top: 8px;
  break-inside: avoid;
}
.figure .fig-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem;
}
.figure .fig-no { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 400; white-space: nowrap; }
.figure .fig-sub { font-size: 0.8rem; color: var(--ink-3); font-style: italic; margin-top: 1px; }
.figure .fig-plot { position: relative; height: 230px; margin-top: 10px; }
.figure .fig-plot.tall { height: 300px; }
.figure .fig-caption {
  margin-top: 8px; padding-top: 6px;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.78rem; color: var(--ink-2); line-height: 1.4;
}
.figure .fig-caption b { font-family: var(--display); }

.fig-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.86rem; }
.fig-table th, .fig-table td { padding: 4px 6px; border-bottom: 1px dotted var(--rule-soft); text-align: left; }
.fig-table th { font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--rule); }
.fig-table td.num, .fig-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fig-table .swatch { display: inline-block; width: 9px; height: 9px; margin-right: 8px; vertical-align: middle; }

.fig-toggle { border: 0; background: transparent; padding: 0; font: inherit; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.fig-toggle:hover { color: var(--ink); }

.fig-state { padding: 26px 10px; text-align: center; font-style: italic; color: var(--ink-3); font-size: 0.9rem; border: 1px dotted var(--rule-soft); margin-top: 10px; }
.fig-state.error { color: #7f1d1d; font-style: normal; }
.fig-state.error b { display: block; font-family: var(--display); font-style: italic; margin-bottom: 4px; }

/* By the numbers */
.numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 6px 0 22px;
}
.number {
  padding: 12px 12px 10px;
  border-right: 1px solid var(--rule-soft);
  text-align: center;
}
.number:last-child { border-right: 0; }
.number .n { font-family: var(--display); font-weight: 900; font-size: 2.2rem; line-height: 1; color: var(--green-ink); font-variant-numeric: tabular-nums; }
.number .n.muted { color: var(--ink-3); }
.number .l { margin-top: 6px; font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }

/* Two-column story text */
.columns { column-count: 2; column-gap: var(--col-gap); column-rule: 1px solid var(--rule-soft); font-size: 0.93rem; }
.columns p { margin-bottom: 10px; }

/* ---------------------------------------------------------------------------
   Wire column: latest dispatches
   ------------------------------------------------------------------------- */

.dispatches { list-style: none; margin: 0; padding: 0; }
.dispatch { padding: 8px 0; border-bottom: 1px dotted var(--rule-soft); font-size: 0.86rem; }
.dispatch .d-time { font-size: 0.72rem; letter-spacing: 0.08em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.dispatch .d-head { font-family: var(--display); font-weight: 700; }
.dispatch .d-head .op { font-weight: 400; font-style: italic; color: var(--ink-2); }
.dispatch .d-head .op.create { color: var(--green-ink); }
.dispatch .d-head .op.delete { color: #7f1d1d; }
.dispatch .d-changes { margin: 4px 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--ink-2); }
.dispatch .d-changes li { display: flex; gap: 6px; }
.dispatch .d-changes li span:first-child { color: var(--ink-3); flex: 0 0 auto; }
.dispatch .d-changes li span:last-child { overflow-wrap: anywhere; }
.wire-empty { font-style: italic; color: var(--ink-3); font-size: 0.86rem; padding: 10px 0; }
.wire-foot { margin-top: 12px; font-size: 0.74rem; color: var(--ink-3); border-top: 1px solid var(--rule-soft); padding-top: 6px; line-height: 1.4; }

/* "Stop press" toasts */
.stop-press { position: fixed; right: 20px; bottom: 20px; width: min(340px, calc(100vw - 40px)); display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.press {
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 4px 4px 0 var(--rule);
  padding: 10px 12px;
  font-size: 0.86rem;
  animation: rise 0.18s ease-out;
}
.press .p-label { font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--green-ink); }
.press .p-head { font-family: var(--display); font-weight: 700; margin-top: 2px; }
.press .p-body { color: var(--ink-2); margin-top: 2px; font-size: 0.8rem; }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.updated-flag { font-size: 0.74rem; color: var(--ink-3); font-style: italic; }

/* Footer folio */
.folio { margin-top: 30px; border-top: 3px double var(--rule); padding-top: 8px; display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------------------------------------------------------------------------
   Responsive: the index becomes a strip, the wire drops below the stories
   ------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .broadsheet { grid-template-columns: 160px minmax(0, 1fr); }
  .wire-col { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rule); padding-left: 0; padding-top: 12px; margin-top: 20px; }
}

@media (max-width: 760px) {
  :root { --gutter: 14px; }
  .broadsheet { grid-template-columns: 1fr; }
  .index-col { border-right: 0; padding-right: 0; margin-bottom: 14px; }
  .index-list { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .index-link { border-bottom: 0; padding: 4px 0; }
  .index-link .pg, .index-note { display: none; }
  .columns { column-count: 1; }
  .ears { grid-template-columns: 1fr; text-align: center; }
  .ears .ear-right { text-align: center; }
  .figures, .figures.two { grid-template-columns: 1fr; }
}

#components-reconnect-modal { font-family: var(--body); }
