/* layout.css — structural styles for all encre pages */
/* Global font smoothing — fixes thin text in Safari */
html, body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

body {
  font-family: var(--font-body);
  font-feature-settings: "tnum";
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: var(--leading-body, 1.5);
  font-size: var(--text-base, 16px);
  font-weight: 400;
}

a { color: inherit; text-decoration: none; }

/* === MASTHEAD === */
.masthead { border-bottom: 2px solid var(--fg); padding: 28px 0 12px; }
.masthead-inner { max-width: var(--container-max, 860px); margin: 0 auto; padding: 0 32px; }
.masthead-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.masthead-date {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.masthead-tagline {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.masthead-brand {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 400;
  letter-spacing: var(--tracking-display, -0.03em);
  line-height: 1;
  margin-bottom: 12px;
}
.masthead-brand a { color: var(--accent); }

/* === NAVBAR === */
.navbar { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); position: relative; }
.navbar-inner {
  justify-content: center;
  max-width: var(--container-max, 860px);
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  overflow: visible;


}
.navbar-inner::-webkit-scrollbar { display: none; }
.navbar a {
  display: block;
  padding: 10px 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--fg-2);
  white-space: nowrap;
  transition: color 0.15s;
}

.navbar a:hover { color: var(--accent); }
.navbar .nav-search,
.navbar .theme-toggle,
.navbar .theme-selector {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 8px;
  white-space: nowrap;
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
}
.navbar .nav-search:hover,
.navbar .theme-toggle:hover,
.navbar .theme-selector:hover { color: var(--accent); }
.navbar .nav-search { margin-left: auto; }

/* Nav dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
  padding: 10px 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--fg-2);
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.nav-dropdown-trigger:hover { color: var(--accent); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 0);
  padding: 8px 0;
  min-width: 120px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 100;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--fg-2);
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.nav-dropdown-menu a:hover { color: var(--accent); background: var(--surface-warm); }

/* === MAIN === */
.main { max-width: var(--container-max, 860px); margin: 0 auto; padding: 32px; }
.main--narrow { max-width: var(--content-width, 720px); }

/* === FOOTER === */
.site-footer { border-top: 2px solid var(--fg); margin-top: 48px; padding: 24px 32px; }
.site-footer-inner {
  max-width: var(--container-max, 860px);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-footer p {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--muted);
}
.site-footer a {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--muted);
  margin-left: 16px;
}
.site-footer a:hover { color: var(--accent); }

/* === SEARCH OVERLAY === */
.search-overlay { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.6); padding: 80px 24px; backdrop-filter: blur(2px); }
.search-overlay.open { display: block; }
.search-box { max-width: 600px; margin: 0 auto; background: var(--surface); border-radius: var(--radius-sm, 0); box-shadow: 0 16px 48px rgba(0,0,0,0.2); overflow: hidden; }
.search-box input {
  width: 100%;
  background: var(--surface);
  border: none;
  border-bottom: 2px solid var(--border);
  color: var(--fg);
  padding: 18px 20px;
  font-family: var(--font-body);
  font-feature-settings: "tnum";
  font-size: 17px;
  outline: none;
}
.search-box input:focus { border-bottom-color: var(--accent); }
.search-loading { padding: 12px 20px; font-size: 12px; color: var(--muted); }
.search-empty { padding: 20px; font-size: 14px; color: var(--muted); text-align: center; }
.search-results { max-height: 60vh; overflow-y: auto; }
.search-results a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border-soft);
  font-size: 15px;
  line-height: 1.4;
  transition: background 0.1s;
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--surface-warm); }
.search-results a:hover .search-result-title { color: var(--accent); }
.search-result-title { flex: 1; min-width: 0; }
.search-result-series { font-family: var(--font-display); font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.search-close { position: absolute; top: 24px; right: 24px; background: none; border: none; color: rgba(255,255,255,0.7); font-size: 28px; cursor: pointer; transition: color 0.15s; }
.search-close:hover { color: #fff; }

/* === TWO COLUMN GRID === */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .masthead-brand { font-size: 28px; }
  .main { padding: 20px 16px; }
  .masthead-inner { padding: 0 16px; }
  .navbar-inner { padding: 0 16px; }
  .navbar a {
 padding: 8px 10px; font-size: 12px; }
  .masthead-tagline { display: none; }
  .two-col { grid-template-columns: 1fr; gap: 32px 0; }
  .site-footer-inner { flex-direction: column; gap: 8px; }
}

/* ── Unified proportional layout ──────────────────────────── */
.masthead-inner,
.navbar-inner {
  max-width: 60%;
  margin: 0 auto;
}
.site-footer-inner {
  max-width: 60%;
  margin: 0 auto;
}
@media (max-width: 1200px) {
  .masthead-inner, .navbar-inner, .site-footer-inner { max-width: 75%; }
}
@media (max-width: 768px) {
  .masthead-inner, .navbar-inner, .site-footer-inner { max-width: 100%; padding: 0 16px; }
}

/* ── Masthead centering ───────────────────────────────────── */
.masthead {
  text-align: center;
}
.masthead-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.masthead-top {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 1rem;
}
.masthead-brand {
  text-align: center;
}
.navbar-inner {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

/* === MOBILE HAMBURGER MENU === */
.navbar-links { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; }
.navbar-burger { display: none; }

@media (max-width: 768px) {
  .navbar-links { display: none; }
  .navbar-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    margin-left: auto;
  }
  .burger-line {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--fg);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .burger-line.open:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
  .burger-line.open:nth-child(2) { opacity: 0; }
  .burger-line.open:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

  .navbar-mobile-menu {
    display: flex;
    flex-direction: column;
    padding: 8px 24px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }
  .navbar-mobile-menu a {
    display: block;
    padding: 12px 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    color: var(--fg-2);
    text-decoration: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .navbar-mobile-menu a:last-child { border-bottom: none; }
  .navbar-mobile-menu a.active { color: var(--accent); font-weight: 700; }
  .navbar-mobile-menu a:hover { color: var(--accent); }

  /* Hide search on mobile navbar */
  .navbar .nav-search,
  .navbar .theme-toggle,
  .navbar .theme-selector { display: none !important; position: static !important; }
}

/* ── 404 Not Found ─────────────────────────────── */
.not-found-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem;
}

.not-found-content {
  text-align: center;
  max-width: 480px;
}

.not-found-code {
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: 6rem;
  font-weight: 900;
  color: var(--border, #d4d6dc);
  line-height: 1;
  display: block;
  margin-bottom: 1rem;
}

.not-found-title {
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg, #1a1a2e);
  margin: 0 0 0.75rem;
}

.not-found-desc {
  font-size: 1rem;
  color: var(--muted, #6b7280);
  line-height: 1.6;
  margin: 0 0 2rem;
}

.not-found-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.not-found-btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: var(--accent, #1a3a6b);
  color: var(--accent-on, #fff);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
  transition: opacity 0.15s;
}

.not-found-btn:hover {
  opacity: 0.85;
}

.not-found-link {
  font-size: 0.9rem;
  color: var(--accent, #1a3a6b);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.not-found-link:hover {
  opacity: 0.7;
}

/* Global: no text-transform anywhere (CJK site, uppercase is meaningless) */
* { text-transform: none !important; }

/* ── Skip link (accessibility) ─────────────────────── */
.skip-link {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: 0.75rem 1.5rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--accent, #1a3a6b);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 99999;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}

/* === RESPONSIVE IMAGES === */
.article-body img,
.article-content img,
article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}


/* ── Footer ──────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border, #e5e7eb);
  margin-top: 3rem;
  padding: 2.5rem 0 2rem;
}

.site-footer-inner {
  max-width: var(--container-max, 860px);
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #6b7280);
  margin: 0 0 0.4rem;
  font-family: var(--font-ui, system-ui, sans-serif);
}

.footer-col a {
  font-size: 0.85rem;
  color: var(--fg-2, #444);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-col a:hover {
  color: var(--accent, #1a3a6b);
}

.footer-bottom {
  text-align: center;
}

.footer-bottom p {
  font-size: 0.75rem;
  color: var(--muted, #6b7280);
  margin: 0 0 0.25rem;
}

.footer-note {
  font-size: 0.7rem;
  opacity: 0.6;
}

@media (max-width: 600px) {
  .site-footer {
    padding: 24px 20px;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem 1.5rem;
  }
  .footer-grid .footer-col:last-child {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.3rem 1.2rem;
  }
  .footer-grid .footer-col:last-child .footer-heading {
    width: 100%;
  }
  .footer-col a {
    font-size: 0.8rem;
  }
  .footer-heading {
    font-size: 0.7rem;
  }
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
