/* site-rail.css — the ONE left-rail stylesheet for tech.jemxx.dev.
 *
 * Every page on the site shows the same rail: the Astro pages render it from
 * src/data/rail.json through BaseLayout, and every other page (the news/NDRC
 * scrapers, the LNG explorer apps, the map dashboards) gets the identical
 * markup stamped in at build time by scripts/site-rail.mjs. Both read the same
 * JSON and both style it from this file — so a link added once appears on all
 * of them, and nothing can drift.
 *
 * Tokens are namespaced --sr-* on purpose: app pages carry their own
 * --text/--muted/--border and must keep them for their own content.
 */

:root {
  --rail: clamp(210px, 17vw, 300px);
  --sr-text: #151a1e;
  --sr-muted: #5d6570;
  --sr-muted-light: #8e98a1;
  --sr-border: #dfe2e8;
  --sr-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- the rail itself ---------- */
/* One dark slab on every page (2026-11-03). It used to be transparent, which
   worked on the homepage because the photo behind it was dark anyway, but on
   the news, football and regional pages the paper-white page showed through
   and the chrome disappeared the moment you left the front page. The rail is
   the one thing that does not change between pages, so it now paints its own
   ground and only the content to its right is light. */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  background: linear-gradient(180deg, #111518 0%, #0b0e11 100%);
  border-right: 1px solid rgba(241, 238, 229, 0.1);
  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: #f1eee5;
  line-height: 1;
  text-decoration: none;
  display: block;
  flex: 0 0 auto;
}
.brand:hover { color: #f1eee5; opacity: 0.55; }
.brand small {
  display: block;
  font-family: var(--sr-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: rgba(241, 238, 229, 0.5);
  margin-top: 9px;
  text-transform: none;
}

/* Homepage view counter, under the brand. Hidden until the number arrives. */
.views {
  font-family: var(--sr-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(241, 238, 229, 0.45);
  margin: 14px 0 0;
}

/* global.css styles the bare `nav` element as the old top bar — neutralise that
   here, or the rail gets a white slab behind the menu. */
.rail .menu {
  display: flex;
  flex-direction: column;
  margin-top: clamp(2rem, 9vh, 5rem);
  position: static;
  background: none;
  border: 0;
  padding: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: auto;
}
.menu .grp {
  font-family: var(--sr-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(241, 238, 229, 0.4);
  margin: 1.5rem 0 0.5rem;
}
.menu .grp:first-child { margin-top: 0; }
.menu .item {
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: rgba(241, 238, 229, 0.68);
  text-decoration: none;
  line-height: 2.5;
  transition: color 0.25s ease;
  display: block;
}
.menu .item:hover { color: #fff; }
.menu .item.is-active { color: #fff; font-weight: 500; }
/* Nested under a sub-group heading (Regional news). */
.menu .item.sub { padding-left: 12px; }

.others-set { display: flex; flex-direction: column; }

.railfoot {
  margin-top: auto;
  padding-top: 2rem;
  font-family: var(--sr-mono);
  font-size: 9px;
  color: rgba(241, 238, 229, 0.42);
  letter-spacing: 0.08em;
  line-height: 1.7;
}
.railfoot a { color: rgba(241, 238, 229, 0.42); }

/* ---------- pages the build injects the rail into ----------
 * The rail is fixed, so a page whose content is ordinary flow just needs a
 * left gutter. Pages that position their own frozen boxes (the explorer feed,
 * the rentals map) are marked with their own body class below and shift those
 * boxes instead.
 */
body.site-rail-on { padding-left: var(--rail); }

/* Framed (?): the explorer shows its sub-pages inside its panel, and the parent
   already owns the one menu. The frame drops the rail, loses the gutter, and
   runs flush to the edges — no second sidebar, no inset card (2026-11-02). */
html.is-embedded .rail { display: none !important; }
html.is-embedded body,
html.is-embedded body.site-rail-on { padding-left: 0 !important; }
/* Astro pages put their content in .canvas, which is offset by the rail. With
   the rail gone the offset has to go too, or the page sits 300px to the right
   inside the frame. */
html.is-embedded .canvas { margin-left: 0 !important; }
html.is-embedded body > header,
html.is-embedded body > main { padding-left: 30px !important; padding-right: 26px !important; }

@media (min-width: 901px) {
  /* Explorer feed + torchlight: a fixed 308px sidebar with the reading panel
     to its right. Slide both over by the rail width. */
  body.sr-fixed-shell .sidebar { left: var(--rail); }
  body.sr-fixed-shell .panel { left: calc(var(--rail) + 308px); }

  /* BKK rentals: full-bleed leaflet map plus floating panels. */
  body.sr-map #map { left: var(--rail); }
  body.sr-map #title,
  body.sr-map #legend { left: calc(var(--rail) + 12px); }
  body.sr-map #legend { max-width: min(560px, calc(60vw - var(--rail))); }
}

/* A page that is dark by design (the info/demo player) inverts the rail text,
   otherwise the muted grey disappears into the background. */
body.sr-dark .rail .brand,
body.sr-dark .rail .brand:hover { color: #f1eee5; }
body.sr-dark .rail .brand small { color: rgba(241, 238, 229, 0.55); }
body.sr-dark .menu .item { color: rgba(241, 238, 229, 0.55); }
body.sr-dark .menu .item:hover,
body.sr-dark .menu .item.is-active { color: #f1eee5; }
body.sr-dark .menu .grp { color: rgba(241, 238, 229, 0.4); }

/* ---------- phones: the rail becomes a top bar ---------- */
@media (max-width: 900px) {
  :root { --rail: 0px; }
  .rail {
    /* Sticky, not fixed. The site-wide 30px tickbar is pinned above this bar,
       so the offset has to be 30px either way — but a fixed bar floats over
       the <h1> underneath it, which on every feed page cut the page title in
       half. In flow the bar takes its own height and pushes the content down. */
    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(--sr-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; color: var(--sr-text); }
  .brand small { display: none; }
  .rail .menu { flex-direction: row; gap: 1.1rem; margin: 0; }
  .menu .grp { display: none; }
  /* The bar is light on phones, so the type goes back to ink here — the dark
     slab's light-on-light colours would make the menu vanish. */
  .menu .item { font-size: 10px; line-height: 2; white-space: nowrap; color: var(--sr-muted); }
  .menu .item:hover, .menu .item.is-active { color: var(--sr-text); }
  .menu .item.sub { padding-left: 0; }
  .railfoot { display: none; }
  .others-set { flex-direction: row; gap: 1.1rem; }
  .views { display: none; }

  /* Flow pages put the bar at the top of the page instead of fixing it: the
     demos and dashboards under here carry their own sticky headers, and a
     fixed bar sits on top of them. */
  body.sr-flow .rail { position: static; inset: auto; }
  body.sr-flow { padding-top: 0; }
  body.sr-fixed-shell .sidebar,
  body.sr-fixed-shell .panel { top: 73px; }
  body.sr-map #map { top: 73px; }
  body.sr-dark .rail {
    background: rgba(17, 17, 17, 0.94);
    border-bottom-color: rgba(241, 238, 229, 0.15);
  }
  body.sr-dark .rail .brand,
  body.sr-dark .menu .item { color: rgba(241, 238, 229, 0.75); }
}

/* ---------- Others: fold it, or lock it ----------
 * The grab-bag group is fourteen links deep. It folds to one line on every
 * page; the padlock collapses it and asks for the site password before it
 * opens again. The pages behind it are gated server-side either way — the
 * lock is about keeping the rail short, not about security.
 */
.grp-fold { display: flex; align-items: center; gap: 10px; }
/* The class sets display:flex, which would beat the [hidden] attribute. */
.others-set[hidden] { display: none; }
.fold-btn {
  margin: 0; padding: 0; background: none; border: 0; cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: inherit; text-align: left;
}
.fold-btn:hover { color: var(--sr-text); }
/* A "+" while it is shut, a dash while it is open — otherwise the heading
   looks like a section title that happens to be a button. */
.fold-btn::after { content: "+"; margin-left: 8px; font-size: 11px; opacity: 0.55; }
.fold-btn[aria-expanded="true"]::after { content: "\2212"; }
.grp-fold::after {
  content: ""; order: 2; flex: 1; height: 1px;
  background: currentColor; opacity: 0.16;
}
.grp-fold .lock-btn {
  order: 3; display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; margin: 0; padding: 0;
  background: none; border: 0; border-radius: 2px;
  color: inherit; opacity: 0.45; cursor: pointer;
}
.grp-fold .lock-btn:hover { opacity: 1; }
.grp-fold .lock-btn[aria-pressed="true"] { opacity: 1; color: var(--accent, #ff5349); }

.unlock { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.unlock[hidden] { display: none; }
.unlock input {
  flex: 1; min-width: 0; padding: 5px 8px;
  font-family: var(--sr-mono); font-size: 10px;
  color: var(--sr-text); background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--sr-border); border-radius: 3px;
}
.unlock input:focus { outline: 0; border-color: var(--sr-muted); }
.unlock button {
  padding: 5px 9px; background: none; cursor: pointer;
  font-family: var(--sr-mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: inherit;
  border: 1px solid currentColor; border-radius: 3px; opacity: 0.7;
}
.unlock button:hover { opacity: 1; }
.unlock .err {
  flex-basis: 100%; margin: 1px 0 0;
  font-family: var(--sr-mono); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: #ff6b61;
}

/* An inline glyph in front of a menu row (the Explorer globe). */
.menu .ic {
  display: inline-flex; width: 11px; height: 11px;
  margin-right: 7px; vertical-align: -1px; opacity: 0.7;
}
.menu .ic svg { display: block; width: 100%; height: 100%; }
.lock-btn .ic { margin: 0; width: 12px; height: 12px; opacity: 1; }

/* Phones: the rail is a horizontal strip and every group label is hidden, so
   the Others rows have to stay reachable — never fold it there. */
@media (max-width: 900px) {
  .grp-fold,
  .unlock { display: none; }
  .others-set[hidden] { display: flex !important; }
}
