/* Fonts (self-hosted, SIL Open Font License), reset, typography and the app layout. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../assets/fonts/inter-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../assets/fonts/inter-latin.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: "Fraunces";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin.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: "Fraunces";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin-italic.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;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"], .plain-list { list-style: none; padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

html, body { background: var(--bg); }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
/* Paper texture under everything (original, generated SVG noise). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("../assets/textures/paper.svg");
  opacity: var(--bg-texture-opacity);
  mix-blend-mode: multiply;
}
[data-theme="academia"] body::before,
[data-theme="romantasy"] body::before,
[data-theme="midnight"] body::before { mix-blend-mode: screen; }

h1, h2, h3 { font-weight: var(--fw-semi); line-height: var(--lh-tight); }
.serif { font-family: var(--font-serif); }
a { color: var(--accent); }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 8px; }

/* ---------- Boot splash ---------- */
.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
}
.boot img { border-radius: 14px; opacity: .9; }

/* ---------- Demo bar ---------- */
.demo-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 32px;
  padding: 4px var(--gutter);
  padding-top: max(4px, env(safe-area-inset-top));
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  text-align: center;
}
.demo-bar a { color: inherit; font-weight: var(--fw-semi); white-space: nowrap; }

/* ---------- App layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }

.sidebar { display: none; }

.view {
  display: block;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--gutter) calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + var(--space-7));
  padding-top: max(var(--space-5), env(safe-area-inset-top));
  outline: none;
}
.demo-bar:not([hidden]) ~ .app .view { padding-top: var(--space-5); }

/* Bottom bar (phone / tablet) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding: 0 max(4px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-right));
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border-radius: var(--radius);
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--accent); }
.bottom-nav a[aria-current="page"] svg { stroke-width: 2; }

/* Sidebar (laptop) */
@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .bottom-nav { display: none; }
  .view {
    padding: var(--space-7) var(--gutter) var(--space-8);
  }
  .sidebar {
    position: sticky; top: 0;
    display: flex; flex-direction: column;
    height: 100vh; height: 100dvh;
    padding: var(--space-6) var(--space-4);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
  }
  .demo-bar:not([hidden]) ~ .app .sidebar { height: calc(100dvh - 32px); top: 32px; }
}

.brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-6);
  color: inherit; text-decoration: none;
  font-family: var(--font-serif);
  font-size: 18px; font-weight: var(--fw-semi);
  letter-spacing: .01em;
}
.brand img { border-radius: 7px; }
.brand em { font-style: italic; font-weight: 400; color: var(--gold); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav .nav-group {
  margin: var(--space-5) var(--space-3) var(--space-2);
  font-size: var(--fs-xs);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-muted);
}
.side-nav a {
  display: flex; align-items: center; gap: var(--space-4);
  height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: var(--fw-medium);
  opacity: .88;
}
.side-nav a svg { width: 17px; height: 17px; flex: none; }
.side-nav a:hover { background: var(--sidebar-active); opacity: 1; }
.side-nav a[aria-current="page"] { background: var(--sidebar-active); opacity: 1; font-weight: var(--fw-semi); }
.side-nav a:focus-visible { outline-color: var(--sidebar-text); }

.side-foot {
  margin-top: auto;
  padding: var(--space-5) var(--space-3) 0;
  font-size: var(--fs-xs);
  color: var(--sidebar-muted);
}
