/* ── NOCTIS — Shared Styles ── */

html { scroll-behavior: smooth; }

/* Cross-page view transitions on supporting browsers (Chromium 111+, Safari TP).
   Older browsers ignore this — pages just navigate normally. */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.22s; }

* { margin:0; padding:0; box-sizing:border-box; transition: color 0.3s, background-color 0.3s, border-color 0.3s, box-shadow 0.3s; }

:root {
  --bg: #f0efe9;
  --card-bg: #fff;
  --card-border: #e0deda;
  --text-primary: #0f0f0f;
  --text-secondary: #888;
  --text-muted: #bbb;
  --label: #bbb;
  --icon-bg: #f0efe9;
  --icon-border: #e0deda;
  --icon-stroke: #555;
  --wm-stroke: #e4e2dc;
  --avatar-border: #dddbd6;
  --avatar-bg: #e8e6e0;
  --divider: #ddd;
  --footer-sub: #ccc;
  --toggle-bg: #e0deda;
  --toggle-knob: #fff;
  --tag-bg: #e8e6e0;
  --tag-color: #666;
  --accent: #c63d1f;
  --code-bg: #e8e6e0;
  --code-border: #dddbd6;
  --inline-code-bg: #e4e2dc;
  --link-color: #0f0f0f;
  --blockquote-border: #ccc;
  --blockquote-bg: rgba(0,0,0,0.02);
}

body.dark {
  --bg: #0f0f0f;
  --card-bg: #1a1a1a;
  --card-border: #2a2a2a;
  --text-primary: #f4f3ef;
  --text-secondary: #666;
  --text-muted: #444;
  --label: #444;
  --icon-bg: #111;
  --icon-border: #2a2a2a;
  --icon-stroke: #888;
  --wm-stroke: #1a1a1a;
  --avatar-border: #2a2a2a;
  --avatar-bg: #1a1a1a;
  --divider: #222;
  --footer-sub: #333;
  --toggle-bg: #333;
  --toggle-knob: #f4f3ef;
  --tag-bg: #1e1e1e;
  --tag-color: #888;
  --accent: #c63d1f;
  --code-bg: #161616;
  --code-border: #2a2a2a;
  --inline-code-bg: #222;
  --link-color: #c63d1f;
  --blockquote-border: #333;
  --blockquote-bg: rgba(255,255,255,0.02);
}

body {
  background: var(--bg);
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 20px 80px;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  position: relative; overflow-x: hidden;
  transition: background 0.3s;
}

body::before {
  content: 'NOCTIS';
  position: fixed; bottom: -40px; left: 50%;
  transform: translateX(-50%);
  font-size: 160px; font-weight: 900;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--wm-stroke);
  letter-spacing: -6px;
  pointer-events: none; user-select: none;
  white-space: nowrap; z-index: 0;
  transition: -webkit-text-stroke-color 0.3s;
}

/* Subtle film-grain overlay across the whole page. */
body::after {
  content: '';
  position: fixed; inset: 0;
  z-index: 200; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: multiply;
}
body.dark::after {
  opacity: 0.06;
  mix-blend-mode: screen;
}

.container { position: relative; z-index: 1; width: 100%; max-width: 680px; }

/* ── SITE NAV ── */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center;
  padding: 0 24px; height: 48px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--card-border);
  transition: background 0.3s, border-color 0.3s;
}
.nav-brand {
  font-size: 14px; font-weight: 900; color: var(--text-primary);
  text-decoration: none; letter-spacing: -0.5px;
  margin-right: 28px; flex-shrink: 0;
  transition: opacity 0.15s;
}
.nav-brand:hover { opacity: 0.7; }
.nav-links {
  display: flex; gap: 20px; flex: 1;
}
.nav-link {
  font-size: 11px; font-weight: 400; color: var(--text-muted);
  text-decoration: none; letter-spacing: 0.04em;
  transition: color 0.15s;
  padding: 4px 0;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--text-primary); font-weight: 500; }
.nav-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  margin-left: 12px; flex-shrink: 0;
}
.nav-toggle .toggle-icon { font-size: 11px; user-select: none; color: var(--text-muted); display: flex; align-items: center; }

/* ── LANGUAGE TOGGLE ── */
.nav-lang {
  margin-left: auto; flex-shrink: 0;
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
  padding: 5px 10px; border-radius: 3px;
  background: transparent; color: var(--text-muted);
  border: 0.5px solid var(--card-border);
  cursor: pointer; transition: all 0.15s;
}
.nav-lang:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* ── INDEX-PAGE FLOATING CONTROLS (lang + theme) ── */
.index-controls {
  position: fixed; top: 16px; right: 20px; z-index: 51;
  display: flex; align-items: center; gap: 12px;
}
.index-controls .theme-toggle {
  position: static !important; top: auto !important; right: auto !important;
}

/* ── HAMBURGER ── */
.nav-hamburger {
  display: none; width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  margin-left: auto; padding: 0;
}
.nav-hamburger span {
  display: block; width: 18px; height: 1.5px;
  background: var(--text-primary); border-radius: 1px;
  transition: transform 0.25s, opacity 0.25s;
}
.site-nav.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.site-nav.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
.site-nav.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (max-width: 560px) {
  .nav-hamburger { display: flex; }
  .nav-links {
    display: none; position: absolute; top: 48px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--bg); border-bottom: 0.5px solid var(--card-border);
    padding: 8px 24px 16px;
  }
  .site-nav.nav-open .nav-links { display: flex; }
  .nav-link { padding: 10px 0; }
  .nav-lang { margin-left: auto; }
  .nav-toggle { margin-left: 8px; }
}

body.has-nav { padding-top: 72px; }

/* ── STANDALONE THEME TOGGLE (index page) ── */
.theme-toggle {
  position: fixed; top: 20px; right: 20px; z-index: 50;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.toggle-track {
  width: 36px; height: 20px; background: var(--toggle-bg);
  border-radius: 10px; position: relative; transition: background 0.25s;
  border: 0.5px solid var(--card-border);
}
.toggle-knob {
  width: 14px; height: 14px; background: var(--toggle-knob);
  border-radius: 50%; position: absolute; top: 2px; left: 2px;
  transition: transform 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
body.dark .toggle-knob { transform: translateX(16px); }
.toggle-icon { font-size: 13px; user-select: none; color: var(--text-muted); display: flex; align-items: center; }

/* ── PAGE HEADER (used on sub-pages below nav) ── */
.page-header {
  margin-bottom: 36px;
  opacity: 0; animation: fadeUp 0.4s ease 0.1s forwards;
}
.page-title { font-size: 22px; font-weight: 900; color: var(--text-primary); letter-spacing: -0.5px; }
.page-subtitle { font-size: 10px; color: var(--text-muted); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 2px; }

/* ── SECTION LABEL ── */
.section-label {
  font-size: 9px; color: var(--text-muted); letter-spacing: 0.2em;
  text-transform: uppercase; margin-bottom: 14px; padding-left: 2px;
  opacity: 0; animation: fadeUp 0.4s ease 0.2s forwards;
}

/* ── TAG ── */
.post-tag, .proj-tag {
  font-size: 9px; padding: 2px 8px; border-radius: 2px;
  background: var(--tag-bg); color: var(--tag-color);
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: all 0.18s;
}

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 0.4; transform: scale(1.6); }
}

/* ── FOCUS STYLES (accessibility) ── */
a:focus-visible, button:focus-visible, .nav-toggle:focus-visible, .theme-toggle:focus-visible, .nav-hamburger:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}

/* ── SITE FOOTER ── */
.site-footer {
  margin-top: 60px; padding: 24px 0;
  border-top: 0.5px solid var(--divider);
  text-align: center;
}
.site-footer-brand { font-size: 12px; font-weight: 900; color: var(--text-muted); letter-spacing: -0.3px; }
.site-footer-sub { font-size: 9px; color: var(--text-muted); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 4px; }
.site-footer-links { margin-top: 14px; font-size: 9px; color: var(--text-muted); letter-spacing: 0.15em; text-transform: uppercase; }
.site-footer-links a {
  color: inherit; text-decoration: none;
  border-bottom: 0.5px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.site-footer-links a:hover { color: var(--text-primary); border-bottom-color: var(--text-primary); }

/* ── BACK TO TOP ── */
.back-to-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 40;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card-bg); border: 0.5px solid var(--card-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s, background 0.18s, border-color 0.18s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover {
  background: var(--text-primary); border-color: var(--text-primary);
  transform: translateY(-2px);
}
.back-to-top svg { width: 16px; height: 16px; stroke: var(--text-muted); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.back-to-top:hover svg { stroke: var(--bg); }

/* ── SKIP TO CONTENT (a11y) ── */
.skip-link {
  position: absolute; top: -40px; left: 8px; z-index: 100;
  padding: 8px 16px; background: var(--text-primary); color: var(--bg);
  text-decoration: none; font-size: 12px; font-weight: 500;
  border-radius: 3px; letter-spacing: 0.04em;
  transition: top 0.18s ease;
}
.skip-link:focus { top: 8px; outline: 2px solid var(--accent); }

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .link-card { transform-style: flat !important; }
  .link-card:hover { transform: none !important; }
}
