/* ============================================================
   ELLIOTT TEELING — Portfolio Atlas
   style.css · BASE + PAGE CHROME

   Owns: design tokens (:root), reset, the full-viewport Konva
   #stage container, the aged-paper #vignette, the .topbar
   (brand + category filters + mobile toggle) and the responsive
   rules for that chrome.

   Chart furniture (compass, legend, zoom control, intro hint)
   lives in markers.css; the slide-in placard lives in panels.css.
   Every file consumes the tokens declared here.

   Z-index order:
     stage(0) < vignette(400) < topbar / furniture(600) < panel(1200)
   ============================================================ */

:root {
  --parchment:        #f4efe0;   /* chart base / paper            */
  --parchment-2:      #ece4cf;   /* slightly deeper paper         */
  --parchment-panel:  rgba(244, 239, 224, 0.97);
  --ink:              #2c1810;   /* primary ink / text            */
  --ink-soft:         #5a4632;   /* secondary ink                 */
  --ink-faint:        #8a7457;   /* faint labels                  */
  --seal:             #8b1a1a;   /* deep crimson accent / wax seal*/
  --seal-dark:        #6f1414;
  --gold:             #d4a843;   /* aged gold highlight           */

  /* Category inks — keep in sync with CATEGORY_COLORS in data.js */
  --cat-coastal:        #2a6f8f;
  --cat-remote-sensing: #2d6a4f;
  --cat-gis:            #1d3557;
  --cat-fieldwork:      #b07d2b;
  --cat-page:           #8b1a1a;

  --font-display: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --font-mono:    'Courier Prime', 'Courier New', monospace;

  --panel-w: 408px;

  --z-vignette: 400;
  --z-ui:       600;
  --z-panel:    1200;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
}

body {
  font-family: var(--font-mono);
  color: var(--ink);
  background: var(--parchment);
  overflow: hidden;                 /* the chart is the viewport */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: none;               /* let Konva own gestures    */
}

img { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a { color: var(--seal); text-decoration: none; }

ul { list-style: none; margin: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

/* ── The Konva stage: full-viewport chart surface ───────── */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--parchment);
  z-index: 0;
  cursor: grab;
  /* touch-action does NOT inherit, so it must be set on the touch target
     itself (and Konva's canvases) — without this, mobile browsers (esp. iOS,
     which ignores user-scalable=no) pinch-zoom the whole page instead of
     letting our handler zoom the chart. */
  touch-action: none;
}
#stage .konvajs-content,
#stage canvas { touch-action: none; }
#stage.is-panning { cursor: grabbing; }

/* ── Aged-paper vignette: decorative, never eats clicks ─── */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-vignette);
  background:
    radial-gradient(
      ellipse 120% 120% at 50% 50%,
      rgba(44, 24, 16, 0) 50%,
      rgba(44, 24, 16, 0.08) 72%,
      rgba(44, 24, 16, 0.24) 90%,
      rgba(44, 24, 16, 0.40) 100%
    ),
    radial-gradient(
      ellipse 140% 140% at 50% 50%,
      rgba(212, 168, 67, 0.05) 0%,
      rgba(212, 168, 67, 0) 60%
    );
  box-shadow: inset 0 0 150px 34px rgba(44, 24, 16, 0.18);
}

/* ── Top bar ────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 18px;
  background: linear-gradient(
    180deg,
    rgba(244, 239, 224, 0.98) 0%,
    rgba(244, 239, 224, 0.90) 100%
  );
  border-bottom: 1px solid rgba(139, 26, 26, 0.32);
  box-shadow: 0 2px 16px rgba(44, 24, 16, 0.16);
  backdrop-filter: blur(2px);
}

.topbar__brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
  color: var(--ink);
  flex: 0 0 auto;
}

.topbar__name {
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: 0.4px;
  color: var(--ink);
}

.topbar__role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ── Category filters ───────────────────────────────────── */
.topbar__filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-btn {
  position: relative;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 3px;
  transition: color 0.18s ease, background 0.18s ease;
}

.filter-btn:hover { color: var(--ink); background: rgba(139, 26, 26, 0.07); }

.filter-btn.is-active { color: var(--seal); font-weight: 700; }

.filter-btn.is-active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 2px;
  height: 2px;
  background: var(--seal);
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(139, 26, 26, 0.5);
}

/* Tiny category swatch inside each filter button. */
.filter-btn__key {
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  border: 1px solid rgba(44, 24, 16, 0.4);
  vertical-align: middle;
}
.filter-btn__key--coastal        { background: var(--cat-coastal); }
.filter-btn__key--remote-sensing { background: var(--cat-remote-sensing); }
.filter-btn__key--gis            { background: var(--cat-gis); }
.filter-btn__key--fieldwork      { background: var(--cat-fieldwork); }

/* ── Mobile hamburger toggle (hidden on desktop) ────────── */
.topbar__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 42px; height: 36px;
  padding: 6px 8px;
  border: 1px solid rgba(139, 26, 26, 0.35);
  border-radius: 4px;
  background: var(--parchment-panel);
  flex: 0 0 auto;
}

.topbar__toggle span {
  display: block;
  height: 2px; width: 100%;
  background: var(--seal);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.topbar__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.topbar__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ============================================================
   RESPONSIVE · < 768px — filters collapse behind the hamburger
   ============================================================ */
@media (max-width: 767px) {
  .topbar { padding: 8px 12px; flex-wrap: wrap; }
  .topbar__name { font-size: 18px; }
  .topbar__role { font-size: 9px; }
  .topbar__toggle { display: flex; }

  .topbar__filters {
    flex-basis: 100%;
    order: 3;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 8px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.25s ease, opacity 0.2s ease;
  }

  .topbar__filters.is-open {
    max-height: 360px;
    opacity: 1;
    pointer-events: auto;
    padding-top: 4px;
    border-top: 1px solid rgba(139, 26, 26, 0.2);
  }

  .filter-btn {
    width: 100%;
    text-align: left;
    padding: 12px 8px;
    border-bottom: 1px solid rgba(139, 26, 26, 0.12);
  }

  .filter-btn.is-active::after {
    left: 0; right: auto; top: 8px; bottom: 8px;
    width: 3px; height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .filter-btn,
  .topbar__toggle span,
  .topbar__filters { transition: none !important; }
}
