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

/* ─── Theme Tokens ───────────────────────────────────────────── */
:root {
  --bg:              #F6F7F9;
  --surface:         #FFFFFF;
  --surface-2:       #F0F2F7;
  --surface-hover:   #E8ECFA;
  --text:            #1C1B1F;
  --text-2:          #56556A;
  --text-3:          #9594A8;
  --border:          #E2E2EE;
  --border-2:        #EEEEF4;
  --accent:          #1A73E8;
  --accent-2:        #E8F0FE;
  --accent-text:     #1A73E8;
  --tag-bg:          #E8F0FE;
  --tag-text:        #1558C0;
  --tag-active-bg:   #1A73E8;
  --tag-active-text: #FFFFFF;
  --code-bg:         #F0F2F7;
  --code-border:     #D8DAE8;
  --blockquote:      #C5CAE9;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:       0 4px 16px rgba(0,0,0,.08);
  --shadow-nav:      0 8px 32px rgba(0,0,0,.10);
  --header-h:        56px;
  --ease:            cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg:              #111113;
  --surface:         #1C1C20;
  --surface-2:       #252529;
  --surface-hover:   #2E2E34;
  --text:            #E4E4F0;
  --text-2:          #A2A2B8;
  --text-3:          #60607A;
  --border:          #2C2C36;
  --border-2:        #222228;
  --accent:          #5B9CF6;
  --accent-2:        #162038;
  --accent-text:     #5B9CF6;
  --tag-bg:          #1A2640;
  --tag-text:        #7AB4FF;
  --tag-active-bg:   #5B9CF6;
  --tag-active-text: #0D1117;
  --code-bg:         #252529;
  --code-border:     #333340;
  --blockquote:      #3A3A50;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.3);
  --shadow-md:       0 4px 16px rgba(0,0,0,.4);
  --shadow-nav:      0 8px 32px rgba(0,0,0,.5);
}

/* ─── Base ───────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: "Google Sans Flex", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  transition: background .25s var(--ease), color .25s var(--ease);
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 200;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}

/* Menu toggle button */
.menu-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .15s var(--ease), color .15s var(--ease);
  user-select: none;
}
.menu-toggle:hover { background: var(--surface-2); }
.menu-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.site-title {
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text);
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}

.chevron-icon {
  flex-shrink: 0;
  transition: transform .3s var(--ease);
  color: var(--text-2);
}
.menu-toggle[aria-expanded="true"] .chevron-icon { transform: rotate(180deg); }

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-2);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sun-icon, .moon-icon { display: none; pointer-events: none; }
[data-theme="light"] .sun-icon  { display: block; }
[data-theme="dark"]  .moon-icon { display: block; }

/* ─── Nav Overlay ────────────────────────────────────────────── */
.nav-overlay {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(0,0,0,.35);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
  backdrop-filter: blur(2px);
}
.nav-overlay.visible { opacity: 1; pointer-events: all; }

/* ─── Nav Dropdown ───────────────────────────────────────────── */
.nav-dropdown {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
  max-height: 0;
  overflow: hidden;
  z-index: 180;
  transition: max-height .38s var(--ease), border-color .25s var(--ease);
}
.nav-dropdown.open { max-height: 68vh; }

.nav-inner {
  display: flex;
  flex-direction: column;
  max-height: 68vh;
  overflow: hidden;
}

/* Search row */
.nav-search-row {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-3);
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
  color: var(--text);
}
.nav-search {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: .875rem;
  color: var(--text);
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}
.nav-search::placeholder { color: var(--text-3); }

/* Filter row */
.nav-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 0;
}
.nav-filter-row.hidden { display: none; }
.filter-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
.filter-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}
.filter-tag:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.filter-tag.active { background: var(--tag-active-bg); border-color: var(--tag-active-bg); color: var(--tag-active-text); }

/* Document list */
.nav-documents {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.nav-documents::-webkit-scrollbar { width: 5px; }
.nav-documents::-webkit-scrollbar-track { background: transparent; }
.nav-documents::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.nav-category { margin-bottom: 2px; }

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 5px;
}
.category-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.category-name {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.category-count {
  font-size: .7rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 1px 7px;
}

.doc-list { list-style: none; }

.doc-item a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 18px 9px 30px;
  text-decoration: none;
  color: var(--text);
  border-radius: 0;
  transition: background .12s;
  cursor: pointer;
}
.doc-item a:hover { background: var(--surface-hover); }
.doc-item.active a { background: var(--accent-2); color: var(--accent-text); }
[data-theme="dark"] .doc-item.active a { background: var(--accent-2); }

.doc-item-body { flex: 1; min-width: 0; }
.doc-item-title {
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 1.4;
}
.doc-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.doc-item-date {
  font-size: .72rem;
  color: var(--text-3);
}
.doc-item-tags { display: flex; gap: 4px; flex-wrap: wrap; }

/* Small tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 500;
  white-space: nowrap;
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}

.no-results {
  padding: 24px 18px;
  color: var(--text-3);
  font-size: .875rem;
  text-align: center;
}

/* ─── Main Content ───────────────────────────────────────────── */
.doc-content {
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  padding: 48px 24px 48px;
  display: flex;
  justify-content: center;
}

/* Placeholder */
.doc-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60vh;
  gap: 16px;
  max-width: 360px;
  margin: auto;
}
.placeholder-glyph {
  color: var(--text-3);
  opacity: .5;
}
.placeholder-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-2);
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}
.placeholder-sub {
  font-size: .9rem;
  color: var(--text-3);
  line-height: 1.6;
}

/* Loading */
.doc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  width: 100%;
}
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.doc-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  width: 100%;
}
.doc-error p {
  color: #D32F2F;
  background: #FFEBEE;
  padding: 16px 24px;
  border-radius: 10px;
  font-size: .9rem;
  border: 1px solid #FFCDD2;
}
[data-theme="dark"] .doc-error p {
  color: #EF9A9A;
  background: #1C1010;
  border-color: #4A1515;
}

/* ─── Document Article ───────────────────────────────────────── */
.doc-article {
  width: 100%;
  max-width: 760px;
  animation: fadeUp .25s var(--ease) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Article header */
.doc-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.doc-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--cat-color, var(--accent));
  margin-bottom: 12px;
}
.doc-category-badge::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.doc-title-main {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 12px;
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}

.doc-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.doc-date-main {
  font-size: .8rem;
  color: var(--text-3);
  font-weight: 500;
}
.doc-description {
  font-size: .9rem;
  color: var(--text-2);
  margin-top: 8px;
  line-height: 1.5;
}

.doc-tags-main {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.tag-main {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: .78rem;
}

/* ─── Markdown Body ──────────────────────────────────────────── */
.doc-body { color: var(--text); line-height: 1.75; }

.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4,
.doc-body h5,
.doc-body h6 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.015em;
  color: var(--text);
  font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
  margin: 1.75em 0 .6em;
}
.doc-body h1 { font-size: 1.75rem; margin-top: 0; }
.doc-body h2 { font-size: 1.35rem; padding-bottom: .4em; border-bottom: 1px solid var(--border-2); }
.doc-body h3 { font-size: 1.1rem; }
.doc-body h4 { font-size: 1rem; font-weight: 600; }
.doc-body h5, .doc-body h6 { font-size: .9rem; font-weight: 600; color: var(--text-2); }

.doc-body p { margin: .9em 0; }
.doc-body p:first-child { margin-top: 0; }

.doc-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; transition: color .15s; }
.doc-body a:hover { color: var(--accent-text); }

.doc-body ul, .doc-body ol { padding-left: 1.6em; margin: .8em 0; }
.doc-body li { margin: .3em 0; line-height: 1.7; }
.doc-body li > ul, .doc-body li > ol { margin: .2em 0; }

.doc-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

.doc-body blockquote {
  margin: 1.2em 0;
  padding: .6em 1.2em;
  border-left: 3px solid var(--blockquote);
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 0 6px 6px 0;
  font-style: italic;
}
.doc-body blockquote p { margin: 0; }

/* Inline code */
.doc-body :not(pre) > code {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  font-size: .84em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: .15em .4em;
  border-radius: 5px;
  color: var(--text);
}

/* Code blocks */
.doc-body pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 1.2em 0;
  font-size: .875rem;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.doc-body pre code {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  font-size: inherit;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  color: var(--text);
}

/* Tables */
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: .9rem;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.doc-body th {
  background: var(--surface-2);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: .82rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.doc-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: top;
}
.doc-body tr:last-child td { border-bottom: none; }
.doc-body tr:hover td { background: var(--surface-2); }

/* Images */
.doc-body img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin: 1.2em auto;
}

/* Task lists */
.doc-body input[type="checkbox"] { margin-right: .5em; }

/* ─── Redaction ──────────────────────────────────────────────── */
.redacted {
  display: inline-block;
  background: #000000;
  color: transparent;
  border-radius: 3px;
  padding: 0 4px;
  cursor: not-allowed;
  user-select: none;
  letter-spacing: -.02em;
  position: relative;
  transition: filter .2s;
}
.redacted::selection { background: transparent; }
.redacted, .redacted *,
.doc-body .redacted a,
.doc-body .redacted a:hover { color: transparent !important; text-decoration: none; }

/* Hover to reveal blur effect — optional, comment out to keep fully hidden */
.redacted:hover {
  background: #111111;
  filter: none;
}

/* ─── Scrollbar (global) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 24px;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}

.footer-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 2px;
}

.footer-primary {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
}

.footer-links {
  font-size: .75rem;
  color: var(--text-3);
}

.footer-copy { color: var(--text-3); }

.footer-sep {
  color: var(--text-3);
  opacity: .4;
  padding: 0 5px;
  user-select: none;
}

.footer-primary a,
.footer-links a {
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}
.footer-primary a:hover { color: var(--accent); }
.footer-links a:hover   { color: var(--text-2); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .doc-content { padding: 32px 16px 64px; }
  .doc-title-main { font-size: 1.5rem; }
  .doc-body h1 { font-size: 1.4rem; }
  .doc-body h2 { font-size: 1.2rem; }
  .nav-dropdown.open { max-height: 75vh; }
  .footer-sep { padding: 0 3px; }
}
