/* ==========================================================================
   feed.css — the house shell for the three generated Feed pages.
   Linked (not inlined) by:
       public/news/world-news.html   <- work-projects/NEWS/ft_combine.py
       public/news/esdm.html         <- work-projects/NEWS/esdm_news.py
       public/ndrc/dashboard.html    <- work-projects/NDRC/scripts/build_dashboard.py
   One edit here restyles all three — that is the whole point of the file.
   Tokens + rail mirror src/layouts/BaseLayout.astro and src/styles/global.css.
   The rail MARKUP still lives in each generator (it has to be in the HTML);
   if you change the rail, change it in all three generators.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Kpler design tokens — identical to global.css */
  --bg: #f2f4f7;
  --surface: #ffffff;
  --card: #ffffff;
  --border: #dfe2e8;
  --accent: #ff5349;
  --accent-dim: #ff371e;
  --accent-light: #ffdcda;
  --text: #151a1e;
  --text-body: #29333c;
  --muted: #5d6570;
  --muted-light: #8e98a1;
  --dark: #151a1e;
  --font: 'Outfit', Tahoma, system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --accent-tint: rgba(255, 83, 73, 0.07);
  --ease: cubic-bezier(0.19, 1, 0.22, 1);

  --canvas: #ffffff;
  --rail: clamp(210px, 17vw, 300px);
}

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

html { scroll-behavior: smooth; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text-body);
  font-size: 0.95rem;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-dim); }

::selection { background: var(--accent); color: #fff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* --------------------------------------------------------------------------
   Fixed left rail — copy of the BaseLayout treatment
   -------------------------------------------------------------------------- */

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  background: none;
  display: flex;
  flex-direction: column;
  padding: 34px 20px 30px 34px;
  z-index: 40;
  overflow-y: auto;
}

.brand {
  font-size: 17px;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
  text-decoration: none;
  display: block;
  flex: 0 0 auto;
}
.brand:hover { color: var(--text); opacity: 0.55; }
.brand small {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-top: 9px;
  text-transform: none;
}

.menu {
  display: flex;
  flex-direction: column;
  margin-top: clamp(2rem, 9vh, 5rem);
}

.menu .grp {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.5rem 0 0.5rem;
}
.menu .grp:first-child { margin-top: 0; }

.menu .grp-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.25s ease;
}
.menu .grp-btn::after { content: " +"; font-size: 11px; color: var(--accent); }
.menu .grp-btn[aria-expanded="true"]::after { content: " –"; }
.menu .grp-btn:hover { color: var(--muted); }

.menu .item {
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  line-height: 2.5;
  transition: color 0.25s ease;
  display: block;
}
.menu .item:hover { color: var(--text); }
.menu .item.is-active { color: var(--text); font-weight: 500; }
/* Nested under a sub-group heading (Regional news). */
.menu .item.sub { padding-left: 12px; }

.others-set { display: flex; flex-direction: column; }
.others-set[hidden] { display: none; }

.railpw { display: flex; flex-direction: column; gap: 6px; margin-top: 0.6rem; }
.railpw[hidden] { display: none; }
.railpw input {
  width: 100%;
  max-width: 190px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
}
.railpw-go {
  appearance: none;
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.railpw-go:hover { color: var(--accent); border-color: var(--accent); }
.railpw-err { font-family: var(--mono); font-size: 9.5px; color: var(--accent); }
.railpw-err[hidden] { display: none; }

.railfoot {
  margin-top: auto;
  padding-top: 2rem;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted-light);
  letter-spacing: 0.08em;
  line-height: 1.7;
}
.railfoot a { color: var(--muted-light); }

/* --------------------------------------------------------------------------
   White canvas
   -------------------------------------------------------------------------- */

.canvas {
  margin-left: var(--rail);
  background: var(--canvas);
  min-height: 100vh;
  padding: 46px clamp(26px, 4.5vw, 72px) 90px;
}
.canvas .inner { max-width: min(1600px, 100%); }

.canvas footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-light);
}
.canvas footer a { color: var(--muted-light); }
.canvas footer a:hover { color: var(--accent); }

/* Page head — serif display, muted standfirst, count badge */
.page-head { margin-bottom: 1.6rem; }
.page-head h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.5vw + 0.6rem, 2.3rem);
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--text);
}
.page-head .subtitle {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.page-head .subtitle strong { font-weight: 600; color: var(--text-body); }

.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  white-space: nowrap;
}

.count {
  margin-top: 1.2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--muted-light);
}

/* --------------------------------------------------------------------------
   Feed table — the /news Skynet treatment: red spine, hairline rows
   -------------------------------------------------------------------------- */

.sheet { position: relative; }
.sheet::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.sheet-inner {
  margin-left: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.sheet-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.84rem;
}

th {
  font-family: var(--mono);
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-light);
  text-align: left;
  padding: 0.75rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-body);
  line-height: 1.45;
}
tbody tr:last-child td { border-bottom: none; }

tbody tr { transition: background 0.15s; }
tbody tr:hover td { background: var(--bg); }

.date-cell {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.time-cell {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted-light);
  white-space: nowrap;
}
.title-cell { color: var(--text); font-weight: 400; position: relative; }
.title-cell .title-link { color: var(--text); font-weight: 400; }
.title-cell:hover .title-link { color: var(--accent); }

.src-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--bg);
  color: var(--muted);
}
a.src-pill:hover { color: var(--accent); background: var(--accent-tint); }

.entity-cell { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.entity-cell strong { font-weight: 600; color: var(--text-body); }

/* Highlighted rows (Trump / oil-price) */
tr.trump-row td, tr.hl td { background: var(--accent-tint); }
tr.trump-row:hover td, tr.hl:hover td { background: var(--accent-light); }

/* Inline expandable body (world news) */
.row-expand { display: none; }
.row-expand.open { display: table-row; }
.row-expand td { background: var(--bg); padding: 0.8rem 1rem; }
.row-expand .exp-body {
  font-size: 0.84rem;
  color: var(--text-body);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-expand .exp-body.loading { color: var(--muted-light); font-style: italic; }
.row-expand .exp-src { margin-top: 0.5rem; font-size: 0.78rem; }
.row-expand .exp-src a { font-weight: 500; }
.exp-err { color: var(--accent-dim); }

/* Hover tooltip on a title */
.title-cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  background: var(--dark);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 400;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  white-space: normal;
  max-width: 420px;
  width: max-content;
  line-height: 1.45;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(21, 26, 30, 0.25);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Slide-out reader (esdm)
   -------------------------------------------------------------------------- */

.reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 26, 30, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s;
  z-index: 2000;
}
.reader-overlay.open { opacity: 1; visibility: visible; }

.reader {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(460px, 92vw);
  background: var(--surface);
  box-shadow: -8px 0 32px rgba(21, 26, 30, 0.18);
  transform: translateX(100%);
  transition: transform 0.28s var(--ease);
  z-index: 2001;
  display: flex;
  flex-direction: column;
}
.reader.open { transform: translateX(0); }
.reader-head {
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}
.reader-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}
.reader-close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted-light);
  cursor: pointer;
  padding: 0 0.2rem;
}
.reader-close:hover { color: var(--accent); }
.reader-meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--muted-light);
  padding: 0.6rem 1.3rem 0;
}
.reader-body { padding: 0.7rem 1.3rem 1.6rem; overflow-y: auto; flex: 1; }
.reader-body p { margin-bottom: 0.85rem; font-size: 0.88rem; line-height: 1.7; color: var(--text-body); }
.reader-body mark { background: transparent; color: inherit; padding: 0; font-weight: inherit; }
/* Highlighting inside a reader body: YEARS and dates red, prices/numbers blue. */
.reader-body mark.hl-date { background: var(--accent-light); color: #c8241a; padding: 0 3px; border-radius: 3px; font-weight: 600; }
.reader-body mark.hl-num { background: #e3f2fd; color: #0d47a1; padding: 0 3px; border-radius: 3px; font-weight: 600; }

/* --------------------------------------------------------------------------
   Sector tags — the small category chip on a feed row
   -------------------------------------------------------------------------- */

.cat {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.56rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--bg);
  color: var(--muted);
}
.cat-oil { background: var(--accent-tint); color: var(--accent); }
.cat-gas { background: #e3f2fd; color: #0d47a1; }
.cat-coal { background: #eceff1; color: #37474f; }
.cat-power { background: #fff8e1; color: #a1680a; }
.cat-minerals { background: #efebe9; color: #4e342e; }
.cat-renewables { background: #e8f5e9; color: #1b5e20; }
.cat-policy { background: #f3e5f5; color: #6a1b9a; }
.cat-general { background: var(--bg); color: var(--muted-light); }
.reader-actions {
  padding: 0.9rem 1.3rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}
.reader-actions a { font-weight: 600; font-size: 0.82rem; }
.reader-note { font-family: var(--mono); font-size: 0.66rem; color: var(--muted-light); margin-left: auto; }
details.orig { margin-top: 0.4rem; border-top: 1px dashed var(--border); padding-top: 0.6rem; }
details.orig summary { cursor: pointer; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-light); }
details.orig div { margin-top: 0.5rem; }
details.orig p { font-size: 0.84rem; color: var(--muted); font-style: italic; }
.notrans { font-size: 0.8rem; color: var(--muted-light); font-style: italic; }

/* --------------------------------------------------------------------------
   ICP history strip (inside a feed reader)
   -------------------------------------------------------------------------- */

.icp {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.7rem 0.85rem 0.6rem;
  margin-bottom: 1rem;
}
.icp-head {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 0.6rem;
}
.icp-head span {
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--muted-light);
  text-transform: none;
  margin-left: 0.35rem;
}
.icp-empty { font-size: 0.76rem; color: var(--muted); }
.icp-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 108px;
}
.icp-col {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}
.icp-col i {
  display: block;
  width: 100%;
  max-width: 30px;
  background: #b9c5cf;
  border-radius: 2px 2px 0 0;
  transition: background 0.2s var(--ease);
}
.icp-col:hover i { background: var(--muted); }
.icp-col.is-here i { background: var(--accent); }
.icp-v {
  font-family: var(--mono);
  font-size: 0.56rem;
  color: var(--muted-light);
  margin-bottom: 2px;
  white-space: nowrap;
}
.icp-col.is-here .icp-v { color: var(--accent); font-weight: 600; }
.icp-m {
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.icp-y { font-family: var(--mono); font-size: 0.52rem; color: var(--muted-light); }
.icp-col.is-here .icp-m, .icp-col.is-here .icp-y { color: var(--text); }

/* --------------------------------------------------------------------------
   Vertical timeline — the ESDM feed's list treatment
   -------------------------------------------------------------------------- */

:root { --tl-line: #2e4a5e; }

.timeline { position: relative; margin: 0; padding: 0 0 0 36px; list-style: none; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--tl-line);
  border-radius: 2px;
}
.tl-item {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 1.3rem;
  /* Right padding + negative margin let the selected wash run to the edge of the
     column without moving the item, which would drag the dot off the line. */
  padding: 0.85rem 0.8rem 0.85rem 0;
  margin-right: -0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.tl-dot {
  position: absolute;
  left: -41px;
  top: 1.05rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tl-line);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.tl-item:hover .tl-dot { background: var(--accent); transform: scale(1.2); }
.tl-date {
  flex: 0 0 128px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
}
.tl-main { flex: 1; min-width: 0; color: var(--text); line-height: 1.5; }
.tl-item:hover .tl-main .title-link { color: var(--accent); }
.tl-item .cat { margin-right: 8px; }

/* The row whose article is open in the reader. It stays visible behind the
   dimmed overlay, so it has to read as "this one" through a 45% black wash:
   blue title + blue dot + a pale blue block. These rules come after the :hover
   pair on purpose — same specificity, so order is what keeps the open row blue
   rather than letting a stray hover turn it red. */
.tl-item.is-open { background: #dbe7fd; }
.tl-item.is-open .tl-dot { background: #1a73e8; transform: scale(1.3); }
.tl-item.is-open .tl-main,
.tl-item.is-open .tl-main .title-link { color: #1a73e8; font-weight: 500; }
.tl-item.is-open .tl-date { color: #1a73e8; }

@media (max-width: 900px) {
  .timeline { padding-left: 26px; }
  .tl-dot { left: -31px; }
  .tl-item { flex-direction: column; gap: 0.15rem; }
  .tl-date { flex: none; font-size: 0.72rem; color: var(--muted); }
}

/* --------------------------------------------------------------------------
   Floating refresh button (world news). Two markup generations exist —
   .rf-* from the Mac generator, .news-refresh-* from the VPS one — so both
   shapes are styled here and either can ship.
   -------------------------------------------------------------------------- */

.rf-wrap, .news-refresh-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.rf-btn, .news-refresh-btn {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(21, 26, 30, 0.18);
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.rf-btn:hover, .news-refresh-btn:hover { background: var(--accent-dim); border-color: var(--accent-dim); transform: translateY(-1px); }
.rf-btn:disabled, .news-refresh-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.rf-prog, .news-refresh-bar { width: 200px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; height: 8px; }
.rf-prog { display: none; }
.rf-prog.visible { display: block; }
.rf-fill, .news-refresh-bar-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.4s; }
.rf-fill.done, .news-refresh-bar-fill.done { background: #2e7d32; }

.rf-text, .news-refresh-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--muted-light);
  text-align: right;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 200px;
  margin-bottom: 4px;
}
.rf-elap, .news-refresh-label span:last-child { font-family: var(--mono); color: var(--muted-light); }
.news-refresh-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  box-shadow: 0 8px 24px rgba(21, 26, 30, 0.12);
}
.news-refresh-progress[hidden] { display: none; }

/* --------------------------------------------------------------------------
   Small screens — rail collapses to a top bar, canvas goes full width
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  :root { --rail: 0px; }
  .rail {
    /* Sticky, not fixed, and offset by the 30px tickbar the middleware pins to
       the top of every page. As a fixed bar it sat on top of the <h1> on all
       five feed pages (Bangkok Post included) because .canvas had no idea how
       tall it was; in flow it pushes the content down instead of covering it. */
    inset: auto;
    position: sticky;
    top: 30px;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(242, 244, 247, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-x: auto;
  }
  .brand { font-size: 13px; letter-spacing: 0.2em; }
  .brand small { display: none; }
  .menu { flex-direction: row; gap: 1.1rem; margin: 0; }
  .menu .grp { display: none; }
  .menu .item { font-size: 10px; line-height: 2; white-space: nowrap; }
  .menu .item.sub { padding-left: 0; }
  .railfoot { display: none; }
  .canvas { margin-left: 0; padding: 26px 18px 70px; }
  .sheet-inner { margin-left: 10px; }
}
