/* ═══════════════════════════════════════════════════════════════════
   FLAGPOLES — style.css
   Direction: "Field & Notice" — a specimen-collection / field-journal
   feel. The stage (sky, poles, stickman) stays clean and minimal —
   it's the real content. All the tactile character lives in the UI
   chrome: panels, tabs, cards, log, buttons.

   Structure of this file:
   1. Fonts + reset + custom properties (design tokens)
   2. Layout (scene, sky, ground, log strip)
   3. Poles + flag areas
   4. Flag wave animation
   5. Stickman
   6. Panels (action panel, picker panel)
   7. Flag picker (search, tabs, grid)
   8. Log strip
   9. Menu overlay
   10. Utility classes
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Anton&family=Inter:wght@400;500;600&family=Space+Mono:wght@400;700&display=swap');

/* ── 1. RESET + DESIGN TOKENS ─────────────────────────────────────── */

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

:root {
  /* Colours — change these to retheme the whole piece.
     Fully neutral: black background, white/grey accents. No warm tones. */
  --c-bg:        #1a1818;   /* scene background — true near-black */
  --c-ground:    #101010;   /* ground strip */
  --c-pole:      #cfcfcf;   /* pole shaft + base — light neutral grey */
  --c-text:      #eaeaea;   /* primary text */
  --c-text-dim:  #7d7d7d;   /* secondary / timestamp text */
  --c-panel-bg:  #121212;   /* sliding panel background */
  --c-border:    #2a2a2a;   /* subtle borders — neutral grey hairline */
  --c-accent:    #ffffff;   /* white accent */
  --c-log-bg:    #0a0a0a;   /* log strip background */

  /* Chrome-only tokens */
  --c-paper:   #171717;     /* dark chip/card fill */
  --c-ink:     #eaeaea;     /* text colour on the above */
  --c-brass:   #ffffff;     /* primary highlight — renamed loosely, now white not bronze */
  --c-brass-dim: #999999;
  --c-stamp-red:   #d64545; /* raise/lower ink — clean red */
  --c-stamp-green: #4caf6a; /* raise/lower ink — clean green */
  --c-thread:  #333333;     /* dashed-edge colour */

  /* Reusable grain texture (pure CSS, no image assets) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");

  /* Typography */
  --font-display: 'Anton', 'Arial Narrow', sans-serif; /* headings — bold, neutral, condensed */
  --font-body:  'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono:  'Space Mono', 'Courier New', Courier, monospace;

  /* Sizes */
  /* Pole height: 60vh is a hard floor (never below 60% of page height,
     as requested), 68vh is the preferred value, 82vh is a ceiling so
     it doesn't get absurd on very tall/narrow viewports. Actual flag
     sizing is computed in JS (fitFlagToArea in main.js) relative to
     this and to each pole's real available width, so --flag-w/--flag-h
     below only matter as a first-paint fallback before that runs. */
  --pole-height: clamp(60vh, 68vh, 82vh);
  --flag-w:      clamp(150px, 23vw, 320px);  /* fallback only — see note above */
  --flag-h:      clamp(100px, 15vw, 210px);  /* fallback only — see note above */
  --log-w:       200px;     /* width of log sidebar */
  --ground-h:    56px;      /* height of ground strip */
  --panel-radius: 16px;     /* corner radius for sliding panels */
}

html, body {
  height: 100%;
  overflow: hidden;         /* no scroll — this is a fixed installation */
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
}


/* ── 2. LAYOUT ────────────────────────────────────────────────────── */

/* Main scene — full viewport, flex row:
   [  sky + poles  ] [ log strip ] */
#scene {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100vw;
}

/* Sky — left area containing poles + stickman. Kept clean and quiet —
   this is the real content, not the place for texture. */
#sky {
  flex: 1;
  position: relative;       /* poles + stickman are absolutely positioned inside */
  overflow: hidden;
}

/* Ground strip — sits at the bottom of #sky */
#ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ground-h);
  background: var(--c-ground);
  border-top: 1px solid var(--c-border);
}


/* ── 3. POLES ─────────────────────────────────────────────────────── */

/* Each pole is absolutely positioned in the sky.
   Horizontal positions are set here — adjust left% to space poles differently.
   The pole-wrap is the clickable hit target for the whole pole. */
.pole-wrap {
  position: absolute;
  bottom: var(--ground-h);  /* sits on the ground */
  display: flex;
  flex-direction: column;
  align-items: flex-start;  /* flag extends to the right of the shaft */
  cursor: pointer;
  user-select: none;
  transform: translateX(-50%); /* centre on the left% position */
}

/* Invisible hit-area, fixed to the full vertical span of the pole and
   NOT tied to the flag's raise/lower transform. Without this, the only
   clickable/hoverable region is the 4px shaft (plus the flag's own box,
   which moves as it raises) — a thin, fiddly target and the source of
   flicker on hover. This sits behind everything (z-index 0), doesn't
   change .pole-wrap's own layout box or the translateX(-50%) centring
   math, and still bubbles clicks/hover up to .pole-wrap since it's
   generated content of that element. */
.pole-wrap::before {
  content: '';
  position: absolute;
  top: 0;
  left: -20px;
  width: max(140px, var(--flag-w));
  height: 100%;
  z-index: 0;
}

/* Individual pole positions — change left% to reposition */
#pole-0 { left: 12%; }
#pole-1 { left: 40%; }
#pole-2 { left: 68%; }

/* Pole shaft — the vertical line */
.pole-shaft {
  width: 4px;
  height: var(--pole-height);
  background: var(--c-pole);
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04);
}

/* Base block at the bottom of the shaft */
.pole-base {
  width: 18px;
  height: 8px;
  background: var(--c-pole);
  border-radius: 2px;
  margin-left: -7px;        /* centre it on the shaft */
}

/* Flag area — sits at the top of the pole, to the right of the shaft.
   Uses clip-path for the raise/lower animation (see main.js). */
.flag-area {
  position: absolute;
  top: 0;
  left: 10px;
  z-index: 2;
  width: var(--flag-display-w, var(--flag-w));
  height: var(--flag-display-h, var(--flag-h));
  overflow: visible;
  display: flex;
  align-items: flex-start;
  justify-content: center;

  /* Physical hoist: at rest the flag sits near the base of the pole
     (its hoist point) and travels UP the shaft to the top when raised,
     rather than scaling/morphing in place. --flag-travel is the pixel
     distance from the top (raised = 0) down to that resting point —
     computed in JS from the pole's real shaft height and the flag's
     display height (see computeFlagTravel in main.js). The 45vh
     fallback only matters before JS has run once. */
  transform: translateY(var(--flag-travel, 45vh));
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flag-area.raised {
  transform: translateY(0);
}

/* Whatever actually renders the flag inside .flag-area (canvas, svg,
   or img) should preserve its own aspect ratio and letterbox within
   the container rather than stretching to fill it — this is a safety
   net independent of the JS sizing math above, in case the container
   box itself is ever a different shape than the flag's true ratio. */
.flag-area canvas,
.flag-area svg,
.flag-area img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Empty pole indicator — shown when no flag is flying.
   Styled like a small handwritten field note rather than plain grey
   caption text. */
.pole-empty-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12px;
  color: var(--c-text-dim);
  pointer-events: none;
  white-space: nowrap;
}

/* Hover state — subtle highlight on the shaft */
.pole-wrap:hover .pole-shaft {
  background: #ff7e7e;
  transition: background 0.2s;
}



/* ── 5. STICKMAN ──────────────────────────────────────────────────── */

#stickman {
  position: absolute;
  bottom: var(--ground-h);
  left: -40px;
  width: 150px;
  height: 150px;
  z-index: 3;
  display: none;
}

.stickman-layer {
  position: absolute;
  inset: 0;
  width: 150px;
  height: 150px;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}

.stickman-layer.active {
  opacity: 1;
}

/* ── 6. PANELS (shared styles) ────────────────────────────────────── */

/* Panels slide up from the bottom on mobile.
   On desktop they appear as a bottom sheet.
   Dark kraft-paper background with a faint grain instead of flat colour. */
.panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--c-panel-bg);
  border-top-left-radius:  var(--panel-radius);
  border-top-right-radius: var(--panel-radius);
  border-top: 2px solid var(--c-border);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
  z-index: 100;
  transform: translateY(0);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 85vh;
  overflow-y: auto;
  isolation: isolate; /* keeps the grain pseudo-element's blend mode scoped to this box */
}

/* Grain as a separate, non-animating layer behind the content, rather
   than blended directly on the box that's being transformed. */
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  mix-blend-mode: overlay;
  pointer-events: none;
  border-radius: inherit;
}

/* Small drag handle — a little brass washer instead of a plain bar */
.panel-handle {
  width: 32px;
  height: 6px;
  background: var(--c-brass);
  border-radius: 3px;
  margin: 12px auto 0;
  opacity: 0.8;
  box-shadow: 0 1px 0 rgba(0,0,0,0.3);
}

/* Dimmer overlay behind panels */
#dimmer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}


/* ── 7. FLAG PICKER ───────────────────────────────────────────────── */

#picker-panel {
  display: flex;
  flex-direction: column;
  height: 80vh;
  /* This panel owns its own scrolling via #picker-stage below —
     don't let .panel's overflow-y:auto fight it for the scrollbar. */
  overflow: hidden;
}

#picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;

  max-width: 700px;
  width: 100%;
  margin: 0 auto;

  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

#picker-back {
  background: none;
  border: none;
  color: var(--c-text);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
}

/* Search is the primary action in this panel — larger, solid border,
   and NOT stretched to fill every last pixel of the row (that read as
   "just a plain full-width input" rather than the obvious next step).
   It takes the majority of the row; Random sits inline to its right
   at a fixed, smaller width so the two read as primary/secondary. */
#picker-search {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: 8px;
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
}

#picker-search::placeholder {
  color: var(--c-text-dim);
}

#picker-search:focus {
  border-color: var(--c-text);
}

/* Random — secondary action, fixed width, inline with search rather
   than buried lower in the prompt view. Because it lives in the
   header (not inside #picker-stage's swapped views) it stays visible
   and clickable no matter what's on screen, so it can be hit
   repeatedly rather than only once from an empty state. */
#picker-random {
  flex-shrink: 0;
  background: none;
  border: 1.5px solid var(--c-border);
  border-radius: 8px;
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#picker-random:hover {
  background: var(--c-border);
  border-color: var(--c-text-dim);
}

/* Category filter tabs — small rotated specimen tags with a punched
   grommet, rather than flat pill buttons. */
#picker-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;

  max-width: 700px;
  width: 100%;
  margin: 0 auto;

  padding: 14px 16px 10px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#picker-tabs::-webkit-scrollbar { display: none; }

/* The single scrolling region for the whole picker body — prompt,
   loading, and results all live inside this and it's the element
   main.js listens to for infinite scroll. */
#picker-stage {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
}

.picker-stage-view.hidden { display: none; }

.picker-prompt-text {
  text-align: center;
  color: var(--c-text-dim);
  font-family: var(--font-body);
  font-style: italic;
  font-size: 15px;
  margin: 40px 0 16px;
}

#picker-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 0;
}

.retrieving-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--c-brass);
  animation: retrieve-spin 0.8s linear infinite;
}

@keyframes retrieve-spin { to { transform: rotate(360deg); } }

/* Flag results grid — thumbnails, responsive column count rather than
   a fixed 3 columns, so it doesn't cramp on wide screens or overflow
   on narrow ones. This is the ONLY rule governing #picker-grid's
   layout now — there used to be a second, conflicting one further
   down this file (fixed repeat(3, 1fr)); it's been removed. */
.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 16px;
  padding: 14px 0 12px;
  align-content: start;
}

/* Tags — the signature "specimen tag" element, reused for both the
   picker category filters and the menu nav below. */
.tab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px 6px 18px;
  position: relative;
  border: 1px solid var(--c-thread);
  border-radius: 3px;
  background: var(--c-bg);
  color: var(--c-text-dim);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transform: rotate(-1.2deg);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

/* Punched grommet — small brass dot near the left edge of each tag */
.tab::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c-brass);
  transform: translateY(-50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4) inset;
}

.tab:nth-child(3n)  { transform: rotate(1deg); }
.tab:nth-child(3n+1){ transform: rotate(-1deg); }
.tab:nth-child(3n+2){ transform: rotate(0.4deg); }

.tab.active {
  background: var(--c-brass);
  color: #0a0a0a;
  border-color: var(--c-brass);
  transform: rotate(0deg) scale(1.04);
}

.tab.active::before {
  background: #0a0a0a;
}

/* Individual flag result — no card box, no background, no border, so
   flags of any aspect ratio just sit on the panel background rather
   than looking cramped inside a mismatched box. No hover transform
   either (box-shadow/transform hover animations here were the main
   source of the lag on this grid — removed rather than optimised,
   since it wasn't earning its cost). Selection shows as a simple
   outline on the image, which is cheap to paint. */
.flag-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text);
  text-align: center;
}

.flag-result img {
  width: 100%;
  max-width: 128px;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  border: none;
  background: none;
}

.flag-result.selected img {
  outline: 2px solid var(--c-stamp-red);
  outline-offset: 3px;
}

.flag-result span {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--c-text-dim);
  line-height: 1.35;
  /* Clamp to 2 lines */
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Infinite-scroll "loading more" row at the bottom of the results grid */
#picker-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0 24px;
  color: var(--c-text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#picker-load-more .retrieving-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* Confirm button — centred, fixed to half width rather than spanning
   the full panel */
#picker-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

#raise-confirm {
  width: 60%;
  min-width: 240px;
  max-width: 380px;
  padding: 13px;
  background: var(--c-stamp-green);
  color: #0a0a0a;
  border: none;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

#raise-confirm:hover {
  opacity: 0.92;
}

#raise-confirm:active {
  transform: scale(0.97);
}


/* ── 6b. ACTION PANEL ─────────────────────────────────────────────── */

/* ── ACTION PROMPT ─────────────────────────────────────────────────
   Two overlapping views crossfade via opacity — NOT the .hidden
   utility class, since that's `display: none !important` and can't
   be transitioned. */
#action-prompt {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  pointer-events: none;
  height: 44px; /* reserves layout space since children are absolute */
}

.action-prompt-view {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.action-prompt-view.faded {
  opacity: 0;
}

.prompt-count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-brass);
  background: var(--c-panel-bg);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  padding: 6px 16px;
}

.prompt-hint {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12px;
  color: var(--c-text-dim);
}

/* Everything in the panel is centred to a fixed, comfortable width
   rather than spanning the full sheet edge-to-edge. */
#action-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.action-flag-row,
.action-btn,
.action-used {
  width: 100%;
  max-width: 420px;
}

/* Current flag preview row — dark card, no paper tone */
.action-flag-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--c-paper);
  color: var(--c-text);
  border-radius: 4px;
}

.action-flag-row img {
  width: 56px;
  height: 37px;
  object-fit: contain;   /* fixed, and now the only definition of this rule */
  border-radius: 2px;
}

.action-flag-row .flag-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
}

.action-flag-row .flag-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--c-text-dim);
  margin-top: 2px;
}

/* Action buttons — centred text, no left-align full-bleed rows */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease;
}

.action-btn:hover { border-color: var(--c-brass-dim); }

.action-btn .btn-icon { font-size: 18px; flex-shrink: 0; }
.action-btn .btn-sub  { font-family: var(--font-mono); font-size: 10px; color: var(--c-text-dim); display: block; margin-top: 2px; }

.action-btn.lower  { color: var(--c-stamp-red);   border-color: rgba(214,69,69,0.35); }
.action-btn.raise  { color: var(--c-stamp-green); border-color: rgba(76,175,106,0.35); }

/* Used-action notice */
.action-used {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--c-text-dim);
  text-align: center;
  padding: 12px;
  background: var(--c-bg);
  border-radius: 6px;
}


/* ── 9. LOG STRIP ─────────────────────────────────────────────────── */

/* The log reads like a strip of telegram/ticket slips — a perforated
   left edge and mono type instead of a plain scrolling text list. */
#log-strip {
  width: var(--log-w);
  flex-shrink: 0;
  background: var(--c-log-bg);
  border-left: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px 10px;
}

#log-heading {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-brass);
  margin-bottom: 10px;
  flex-shrink: 0;
}

#log-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: none;
}
#log-list::-webkit-scrollbar { display: none; }

/* Highlight the city name */
.log-entry .log-city { color: var(--c-text); font-weight: 600; }

/* Colour-code raise vs lower */
.log-entry .log-raised  { color: var(--c-stamp-green); }
.log-entry .log-lowered { color: var(--c-stamp-red); }

/* Animate new entries sliding in */
.log-entry.new {
  animation: log-slide 0.4s ease;
}

@keyframes log-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Token code in log */
.log-token {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--c-text-dim);
  opacity: 0.6;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
  color: var(--c-text-dim);
  border-bottom: 1px dashed var(--c-border);
  padding-bottom: 8px;
  position: relative;
}

/* Small perforation dots along the left, like a torn ticket stub */
.log-entry::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 8px;
  width: 1px;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--c-border) 0 3px,
    transparent 3px 7px
  );
}

/* Fixed bounding box — the img inside is constrained to fit within it
   via object-fit, so a tall/narrow flag and a wide/short flag both
   end up "reasonably small" without either stretching or dominating
   the log line. Given a small brass pin corner to match the card motif. */
.log-flag-icon {
  flex-shrink: 0;
  width: 22px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px; /* optical alignment with first line of text */
  background: var(--c-paper);
  border-radius: 2px;
  padding: 1px;
}

.log-flag-icon img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 1px;
}

.log-entry-text {
  flex: 1;
  min-width: 0;
}


/* ── 10. MENU OVERLAY ─────────────────────────────────────────────── */

#menu-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--c-panel-bg);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

#menu-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--c-bg);
  z-index: 300;
  padding: 60px 32px 32px;
  overflow-y: auto;
  isolation: isolate;
}

#menu-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: -1;
}

#menu-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--c-text);
  font-size: 22px;
  cursor: pointer;
}

#menu-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--c-border);
  padding-bottom: 16px;
  flex-wrap: wrap;
}

/* Menu nav reuses the specimen-tag look from the picker tabs */
.menu-tab {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--c-bg);
  border: 1px solid var(--c-thread);
  border-radius: 3px;
  color: var(--c-text-dim);
  cursor: pointer;
  padding: 6px 14px 6px 18px;
  position: relative;
  transform: rotate(-1deg);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.menu-tab::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c-brass);
  transform: translateY(-50%);
}

.menu-tab:nth-child(2) { transform: rotate(0.8deg); }
.menu-tab:nth-child(3) { transform: rotate(-0.6deg); }

.menu-tab.active {
  color: #0a0a0a;
  background: var(--c-brass);
  border-color: var(--c-brass);
  transform: rotate(0deg);
}

.menu-tab.active::before {
  background: #0a0a0a;
}

.menu-page h2 {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 16px;
  letter-spacing: 0.01em;
  color: var(--c-text);
}

.menu-page p {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  color: var(--c-text-dim);
  margin-bottom: 14px;
  max-width: 500px;
}


/* ── 11. UTILITY CLASSES ──────────────────────────────────────────── */

/* Toggle visibility — JS adds/removes this class */
.hidden {
  display: none !important;
}

/* Keyboard focus ring */
:focus-visible {
  outline: 2px solid var(--c-brass);
  outline-offset: 2px;
}

/* Reduced motion — respect user preference */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

a:link {
  color: var(--c-brass);
  background-color: transparent;
  text-decoration: underline dotted;
}