/* ── Fonts (self-hosted, SIL OFL: see static/fonts/LICENSE-*.txt) ──
   Variable files, one per script range; latin-ext carries ă â î ș ț. */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/instrument-sans-latin.fa41c43a3d8e.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/instrument-sans-latin-ext.1ff13d113ba4.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.b058178d7f30.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext.e36841ed93d5.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Design tokens: every stylesheet reads these ── */
:root {
  color-scheme: light;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: #dde5ef;
  --line-strong: #c6d2e2;
  --text: #0e1826;
  --text-2: #3c4a5a;
  --muted: #62738a;

  /* Amber is the one accent. On white it is too light for text, so text uses the ink. */
  --accent: #ffb020;
  --accent-ink: #9a5f00;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent) 40%, transparent);
  --on-accent: #1a1204;

  --ok: #12805c;
  --ok-soft: #e3f5ee;
  --info: #1f6fb2;
  --info-soft: #e6f0fa;
  --danger: #b3261e;
  --danger-soft: #fdecea;

  --aurora-1: rgba(255, 176, 32, 0.2);
  --aurora-2: rgba(47, 143, 212, 0.16);
  --aurora-3: rgba(22, 169, 122, 0.1);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(16, 32, 56, 0.05), 0 12px 28px -12px rgba(16, 32, 56, 0.16);
  --shadow-lg: 0 2px 4px rgba(16, 32, 56, 0.05), 0 28px 60px -22px rgba(16, 32, 56, 0.26);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  --ease: cubic-bezier(0.22, 0.68, 0.28, 1);
  --rail: 1600px;
}

/* Dark theme: set on <html> by the script at the top of base.html's <head>.
   config/tests.py checks that every colour above has a value here. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d14;
  --surface: #0f1824;
  --surface-2: #142132;
  --surface-3: #1a2b3f;
  --line: #1e2f43;
  --line-strong: #2c4159;
  --text: #e8eff7;
  --text-2: #b4c4d6;
  --muted: #7d92aa;

  /* On a dark background the amber itself is readable as text. */
  --accent-ink: #ffb020;

  --ok: #4fd1a1;
  --ok-soft: rgba(62, 207, 142, 0.14);
  --info: #7cb8ec;
  --info-soft: rgba(79, 168, 224, 0.15);
  --danger: #ff8a7d;
  --danger-soft: rgba(255, 107, 94, 0.14);

  --aurora-1: rgba(255, 176, 32, 0.14);
  --aurora-2: rgba(47, 143, 212, 0.16);
  --aurora-3: rgba(22, 169, 122, 0.1);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 34px -18px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 34px 70px -26px rgba(0, 0, 0, 0.9);
}

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

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Soft amber, blue and green glows behind every page. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(48vw 48vw at 4% -12%, var(--aurora-1), transparent 70%),
    radial-gradient(42vw 42vw at 100% -4%, var(--aurora-2), transparent 70%),
    radial-gradient(38vw 38vw at 55% 95%, var(--aurora-3), transparent 70%);
}

h1,
h2,
h3,
h4 {
  line-height: 1.15;
  letter-spacing: -0.02em;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
}

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

/* Read by screen readers, invisible on screen (form labels the layout makes obvious). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Primary action button, shared by the account and messaging pages. */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--on-accent);
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.25s var(--ease);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn-primary:active {
  transform: none;
}

/* Secondary action: white, outlined, amber edge on hover. */
.btn-secondary {
  min-height: 44px;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

/* ── Flash messages ── */
.site-messages {
  list-style: none;
  max-width: 960px;
  margin: 16px auto 0;
  padding: 0 16px;
}

.site-message {
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
  color: var(--ok);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
}

.site-message + .site-message {
  margin-top: 8px;
}

.site-message--error,
.site-message--warning {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--danger);
}

/* ── Header: sticky, frosted ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header-content {
  max-width: var(--rail);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.site-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 11px;
}

/* The logo is dark lines on a transparent PNG: it keeps a white tile in either theme. */
.site-logo img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 11px;
  box-shadow:
    0 0 0 1px var(--line),
    0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.site-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.site-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-tagline {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ── Layout ── */
.main-wrapper {
  flex: 1 0 auto;
  width: 100%;
  padding: 0 24px;
}

/* ── Account nav (right side of the header) ── */
.site-account-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  font-weight: 500;
}

.account-link,
.account-name {
  color: var(--text-2);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition:
    background-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.account-link:hover,
.account-name:hover {
  color: var(--text);
  background: var(--surface-3);
}

.account-name {
  color: var(--text);
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 999px;
}

.account-link-primary {
  color: var(--on-accent);
  background: var(--accent);
  font-weight: 600;
}

.account-link-primary:hover {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}

/* The one call to action in the header: an amber-tinted pill. */
.account-link-sell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin-right: 6px;
  padding: 8px 16px;
  color: var(--text);
  font-weight: 600;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-ring);
}

.account-link-sell::before {
  content: "+";
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-ink);
}

.account-link-sell:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

/* ── Theme switch: shown once the <head> script has picked a theme (so never without JS) ── */
.theme-toggle {
  display: none;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

:root[data-theme] .theme-toggle {
  display: grid;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* The moon offers the dark theme; once on, the sun offers the way back. */
.theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

/* ── Breadcrumbs (shared by every page that renders a trail): a mono eyebrow ── */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.breadcrumbs::before {
  content: "";
  width: 22px;
  height: 1px;
  margin-right: 10px;
  background: var(--accent);
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.breadcrumbs a:hover {
  color: var(--accent-ink);
}

/* Spans are the "/" separators, except the last one: the current page. */
.breadcrumbs span {
  margin: 0 8px;
  color: var(--line-strong);
}

.breadcrumbs span:last-child {
  margin: 0;
  color: var(--accent-ink);
}

/* ── Footer ── */
.site-footer {
  margin-top: clamp(40px, 6vw, 80px);
  padding: 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer-content {
  max-width: var(--rail);
  margin: 0 auto;
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px 32px;
}

.footer-brand strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
}

.footer-brand span {
  display: block;
  max-width: 560px;
  line-height: 1.6;
}

.footer-links,
.footer-social {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 18px;
}

.footer-social {
  grid-column: 2;
}

.footer-links a,
.footer-social a {
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.footer-links a:hover,
.footer-social a:hover {
  color: var(--accent-ink);
}

.footer-legal {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* ── Cookie consent: a floating card ── */
.cookie-consent {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: 460px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 12px 16px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.cookie-consent[hidden] {
  display: none;
}

/* The sentence takes what the two buttons leave, so they stay on one row. */
.cookie-consent span {
  flex: 1 1 200px;
}

.cookie-consent button {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  cursor: pointer;
}

.cookie-consent button[data-consent="granted"] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  /* On a phone the nav wraps to a second row: too tall to stay pinned. */
  .site-header {
    position: static;
    padding: 10px 12px;
  }

  .main-wrapper {
    padding: 0 10px;
  }

  .site-footer {
    padding: 0 12px;
  }

  .site-footer-content {
    grid-template-columns: 1fr;
  }

  .footer-links,
  .footer-social {
    justify-content: flex-start;
  }

  .footer-social {
    grid-column: auto;
  }

  .site-logo img {
    width: 36px;
    height: 36px;
  }

  .site-title {
    font-size: 16px;
  }

  .site-tagline {
    display: none;
  }

  /* The nav wraps to its own row; the switch stays up by the logo. */
  .theme-toggle {
    order: 1;
    margin-left: auto;
    width: 36px;
    height: 36px;
  }

  .site-account-nav {
    order: 2;
  }

  /* Signed in, the nav holds five links: on a phone they wrap rather than push
     the page sideways. */
  .site-account-nav {
    font-size: 13px;
    gap: 2px;
    flex-wrap: wrap;
    max-width: 100%;
  }

  .account-link,
  .account-name {
    padding: 6px 10px;
  }

  .account-link-sell {
    min-height: 36px;
    margin-right: 2px;
  }

  .account-name {
    max-width: 110px;
  }
}

@media (max-width: 420px) {
  .cookie-consent {
    right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
