/* Stylesheet for the Nunjucks-rendered themed public pages (/, /posts/[slug],
   section lists — see lib/theme.ts). Linked, not inlined, on purpose: this
   file is a static asset like support-widget.js, so it's cached by the
   browser across page navigations instead of being re-sent as part of every
   full-page HTML response the way an inline <style> block would be. */

:root {
  color-scheme: light dark;
  --ink: #1a1a1a;
  --ink-muted: #6b7280;
  --bg: #fff;
  --panel: #fff;
  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .12);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .12);
  --on-accent: #ffffff;
  --hover-bg: rgba(0, 0, 0, .06);
  --shadow: 0 8px 24px rgba(0, 0, 0, .12);
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
}

/* Same accent value as app/globals.css's --accent (both light and dark) —
   deliberate: the Nunjucks theme path and the React admin/system path used
   to pick colors independently and happened to already agree on light-mode
   blue; tokenizing both lets them agree on the dark value too instead of
   drifting apart the next time either gets touched. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e8e8;
    --ink-muted: #9aa1ad;
    --bg: #0f1319;
    --panel: #171c24;
    --border: rgba(255, 255, 255, .1);
    --border-strong: rgba(255, 255, 255, .14);
    --accent: #5b8def;
    --accent-soft: rgba(91, 141, 239, .18);
    /* Same fix as app/globals.css's --on-accent: white text on the lighter
       dark-mode accent blue measures ~3.2:1, below WCAG AA. */
    --on-accent: #10151c;
    --hover-bg: rgba(255, 255, 255, .08);
    --shadow: 0 8px 24px rgba(0, 0, 0, .4);
    --danger-bg: rgba(153, 27, 27, .18);
    --danger-border: rgba(153, 27, 27, .45);
    --danger-text: #fca5a5;
  }
}

* {
  box-sizing: border-box;
}

body {
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  max-width: 960px;
  margin: 0 auto;
}

.site-nav .brand {
  font-weight: 700;
  font-size: 18px;
  color: inherit;
  flex-shrink: 0;
}

.brand-logo {
  height: 40px;
  object-fit: contain;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 18px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
}

.nav-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav-account {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  font-size: 13px;
  flex-shrink: 0;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.hero {
  padding: 40px 0;
}

.hero h1 {
  font-size: 32px;
  margin: 8px 0;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.post-list {
  display: grid;
  gap: 20px;
}

.post-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
}

.post-card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

.post-card h2 {
  margin: 6px 0;
}

.post-card .meta {
  font-size: 13px;
  color: var(--ink-muted);
}

.post-cover {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 12px;
  margin: 20px 0;
}

.empty-state {
  color: var(--ink-muted);
  padding: 40px 0;
  text-align: center;
}

.post-meta {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.post-body {
  margin-top: 20px;
  line-height: 1.8;
}

.post-body img {
  max-width: 100%;
}

.theme-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 13px;
}

.site-foot {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
  color: var(--ink-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* Two-level nav dropdown (themes/default/base.njk) — same <details>-based
   mechanism as .nav-lang-menu/.lang-list below (no JS, works with it
   disabled), just triggered by a small caret next to the link instead of
   the link itself, since a parent item is still a real page of its own and
   should stay directly clickable. */
.nav-item-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-item-dropdown > details > summary {
  cursor: pointer;
  list-style: none;
  padding: 4px;
  color: inherit;
  opacity: .65;
  font-size: 11px;
  line-height: 1;
}

.nav-item-dropdown > details > summary::-webkit-details-marker {
  display: none;
}

.nav-item-dropdown > details > summary::marker {
  content: "";
}

.nav-item-dropdown > details > summary::after {
  content: "▾";
}

.nav-dropdown-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  list-style: none;
  margin: 0;
  padding: 6px;
  width: max-content;
  min-width: 140px;
  max-width: min(240px, calc(100vw - 32px));
  z-index: 10;
}

.nav-dropdown-menu li a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: inherit;
  white-space: nowrap;
}

.nav-dropdown-menu li a:hover {
  background: var(--hover-bg);
}

.nav-lang-menu {
  position: relative;
  margin-left: 0;
}

.nav-lang-menu summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  color: inherit;
}

.nav-lang-menu summary::-webkit-details-marker {
  display: none;
}

.nav-lang-menu summary::marker {
  content: "";
}

.lang-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  list-style: none;
  margin: 0;
  padding: 6px;
  width: max-content;
  min-width: 140px;
  max-width: min(220px, calc(100vw - 32px));
  z-index: 10;
}

.lang-list li a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: inherit;
  white-space: nowrap;
}

.lang-list li a:hover {
  background: var(--hover-bg);
}

.lang-list li a.is-current {
  background: var(--accent-soft);
  font-weight: 600;
}

/* 680px matches the PHP predecessor's real-device-verified nav breakpoint —
   reused rather than re-derived. */
@media (max-width: 680px) {
  .site-nav {
    flex-wrap: wrap;
    padding: 14px 20px;
  }

  .nav-toggle {
    display: block;
  }

  .nav-panel {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    width: 100%;
    padding-top: 14px;
    margin-top: 14px;
    border-top: 1px solid var(--border);
  }

  .nav-panel.is-open {
    display: flex;
  }

  .nav-links {
    flex-direction: column;
    gap: 10px;
  }

  .nav-account {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .nav-item-dropdown {
    flex-wrap: wrap;
  }

  .nav-dropdown-menu {
    position: static;
    top: auto;
    margin-top: 6px;
    margin-left: 16px;
    box-shadow: none;
    width: auto;
    max-width: none;
  }

  .nav-lang-menu {
    margin-left: 0;
  }

  .lang-list {
    position: static;
    top: auto;
    margin-top: 8px;
    box-shadow: none;
    width: 100%;
    max-width: none;
  }

  main {
    padding: 24px 20px 60px;
  }

  .hero {
    padding: 28px 0;
  }

  .hero h1 {
    font-size: 26px;
  }
}

/* Support widget (public/nav-toggle.js's sibling, public/support-widget.js)
   — same class names and values as components/SupportWidget.tsx's classes
   in app/globals.css. Two independent implementations (this rendering path
   has no React runtime, see lib/theme.ts's header comment) sharing one
   vocabulary so they don't visually drift apart from each other over time. */

.support-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
}

.support-panel {
  width: 300px;
  max-width: calc(100vw - 40px);
  height: 380px;
  margin-bottom: 12px;
  display: none;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  font: 14px/1.5 -apple-system, sans-serif;
  color: var(--ink);
}

.support-panel.is-open {
  display: flex;
}

.support-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.support-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.support-empty {
  color: var(--ink-muted);
  font-size: 13px;
}

.support-msg {
  max-width: 85%;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
}

.support-msg.is-admin {
  align-self: flex-start;
  background: var(--bg);
  color: inherit;
}

.support-msg.is-visitor {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
}

.support-panel-footer {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.support-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--panel);
  color: var(--ink);
}

.support-send-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  font-size: 13.5px;
}

.support-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}

@media (max-width: 420px) {
  .support-widget {
    right: 12px;
    bottom: 12px;
  }

  .support-panel {
    max-width: calc(100vw - 24px);
  }
}
