/* =========================================================================
   reromanlee.com — base styles & design tokens
   Neutral placeholder palette. Colours/spacing are meant to be replaced by
   the Figma design system later without touching structure or class names.
   ========================================================================= */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-v20-cyrillic_latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Google Sans Code';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/google-sans-code-v17-latin_math_symbols_symbols2-regular.woff2') format('woff2');
}

/* ---- Design tokens ----------------------------------------------------- */
:root {
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Google Sans Code', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --topbar-h: 56px;
  --sidebar-w: 264px;
  --content-max: 800px;
  --radius: 10px;

  /* Light theme (default) */
  --bg: #ffffff;
  --surface: #f6f7f8;
  --surface-2: #eceef0;
  --text: #17181a;
  --text-muted: #5b616a;
  --border: #e2e5e8;
  --accent: #2f6fb0;
  --accent-contrast: #ffffff;
  --overlay: rgba(20, 22, 25, 0.45);

  color-scheme: light;
}

/* Dark tokens, shared by the system-preference fallback and the explicit
   toggle. Kept identical in both blocks below. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181a;
    --surface: #1f2124;
    --surface-2: #292c30;
    --text: #e6e8ea;
    --text-muted: #a2a8b0;
    --border: #34383d;
    --accent: #6fa8dc;
    --accent-contrast: #10233a;
    --overlay: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17181a;
  --surface: #1f2124;
  --surface-2: #292c30;
  --text: #e6e8ea;
  --text-muted: #a2a8b0;
  --border: #34383d;
  --accent: #6fa8dc;
  --accent-contrast: #10233a;
  --overlay: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--topbar-h);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--accent); }

code, pre, kbd, samp { font-family: var(--font-mono); }

.content {
  flex: 1 0 auto;
  width: 100%;
}

/* Centered, readable-width wrapper for text pages (search, recent, …). */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn--icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text);
}
.btn--icon:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 22px; height: 22px; fill: currentColor; }

/* ---- Top app bar ------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__group { display: flex; align-items: center; gap: 4px; }
.topbar__group--start { justify-self: start; }
.topbar__group--end { justify-self: end; }
.topbar__title {
  justify-self: center;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

/* Theme icon: show the target theme's glyph (moon in light, sun in dark). */
.topbar__theme .icon--sun { display: none; }
.topbar__theme .icon--moon { display: block; }
:root[data-theme="dark"] .topbar__theme .icon--sun { display: block; }
:root[data-theme="dark"] .topbar__theme .icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar__theme .icon--sun { display: block; }
  :root:not([data-theme="light"]) .topbar__theme .icon--moon { display: none; }
}

/* ---- Footer ------------------------------------------------------------ */
.footer {
  flex-shrink: 0;
  padding: 24px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.footer__link { color: var(--text-muted); text-decoration: none; }
.footer__link:hover { color: var(--accent); text-decoration: underline; }

/* ---- Sidebar (shared by wiki + home) ----------------------------------- */
.has-sidebar { margin-left: var(--sidebar-w); }

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 90;
}
.sidebar__inner { padding: 16px 12px; }
.sidebar__group {
  margin: 4px 8px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.sidebar__list { list-style: none; margin: 0; padding: 0; }
.sidebar__list li { margin: 2px 0; }
.sidebar__link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}
.sidebar__link:hover { background: var(--surface-2); }
.sidebar__link.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

/* Scrim + menu toggle only matter on narrow screens. */
.sidebar-scrim { display: none; }
.topbar__menu { display: none; }

@media (max-width: 860px) {
  .topbar__menu { display: inline-grid; }
  .has-sidebar { margin-left: 0; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 95;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.25);
  }
  .sidebar-scrim.is-open {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: var(--overlay);
    z-index: 94;
  }
}
