/******************************************************
 * layout.css — Global Layout (Header / Nav / Sidebar / Content / Footer)
 * - Header: .site-header, .main-header, .desktop-header, .mobile-header, .nav-menu, .hamburger, .mobile-menu
 * - Page:   .main-container, .with-sidebar, .sidebar, .content-area, .sidebar-toggle
 * - Extras: .typing-slogan, .visually-hidden, reduced motion, dark mode
 ******************************************************/

/* ===== CSS Vars (light defaults) ===== */
:root {
  --hdr-bg: #fff;
  --hdr-ink: #111;
  --hdr-link: #111;
  --hdr-link-hover: #6e6e6e;
  --hdr-border: #000;
  --hdr-pill: #f5f5f5;

  --page-bg: #ffffff;
  --page-ink: #1a1a1a;
  --page-muted: #666;
  --page-border: #ddd;

  --container-max: 1200px;
}

/* ===== Base Layout Wrapper ===== */
body {
  margin: 0;
  color: var(--page-ink);
  background: var(--page-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ================================
   Header / Navigation (Desktop)
=================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--hdr-bg);
  border-bottom: 1.5px solid var(--hdr-border);
}

.main-header {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Logo */
.logo-box .logo,
.site-header .logo {
  display: inline-block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--hdr-ink);
  text-decoration: none;
  letter-spacing: -0.2px;
}

/* Desktop nav */
.desktop-header {
  display: block;
}
.desktop-header .nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.desktop-header .nav-menu a {
  display: inline-block;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--hdr-link);
  text-decoration: none;
  border-radius: 10px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.desktop-header .nav-menu a:hover {
  background: var(--hdr-pill);
  color: var(--hdr-link-hover);
  transform: translateY(-1px);
}
/* current page */
.desktop-header .nav-menu a.is-active {
  position: relative;
}
.desktop-header .nav-menu a.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 4px;
  height: 2px;
  background: #000;
  border-radius: 2px;
}

/* Optional typing slogan under header */
.typing-slogan {
  font-size: 25px;
  font-weight: 500;
  font-family: "spomono", system-ui, sans-serif;
  white-space: nowrap;
  border-right: 2px solid #000;
  overflow: hidden;
  width: fit-content;
  margin: 24px auto 0;
  min-height: 2em;
  animation: blink-caret 0.75s step-end infinite;
}
@keyframes blink-caret {
  50% {
    border-color: transparent;
  }
}

/* ================================
   Mobile Header / Drawer
=================================== */
.mobile-header {
  display: none;
}

/* burger */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 34px;
  height: 28px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.hamburger span {
  width: 100%;
  height: 3px;
  background: #333;
  border-radius: 2px;
}

/* drawer */
.mobile-menu {
  display: none;
  background: #f8f8f8;
  border-top: 1px solid #e5e5e5;
}
.mobile-menu.active {
  display: block;
}
.mobile-menu ul {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
}
.mobile-menu li {
  border-bottom: 1px solid #e9e9e9;
}
.mobile-menu li:last-child {
  border-bottom: none;
}
.mobile-menu a {
  display: block;
  padding: 14px 8px;
  font-weight: 700;
  color: #333;
  text-decoration: none;
}

/* Breakpoints for header */
@media (max-width: 1024px) {
  .desktop-header .nav-menu {
    gap: 14px;
  }
  .desktop-header .nav-menu a {
    font-size: 1rem;
  }
}
@media (max-width: 768px) {
  .desktop-header {
    display: none;
  }
  .mobile-header {
    display: block;
    width: 100%;
    background: var(--hdr-bg);
    border-bottom: 1px solid #e5e5e5;
  }
  .mobile-header .mobile-top {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

/* ================================
   Page Layout (with optional sidebar)
=================================== */
.main-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.with-sidebar {
  display: flex;
  gap: 24px;
}
.sidebar {
  width: 260px;
  background: #f9f9f9;
  border-right: 1px solid var(--page-border);
  padding: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.content-area {
  flex: 1;
  padding: 20px;
}

/* Sidebar toggle (floating button on mobile) */
.sidebar-toggle {
  display: none;
}

@media (max-width: 768px) {
  .with-sidebar {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 72%;
    height: 100%;
    background: #fff;
    border-right: 1px solid #ddd;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: block !important;
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .content-area {
    position: relative;
    padding: 16px;
  }

  .sidebar-toggle {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #000;
    color: #fff;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 50px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1500;
  }
}

/* ================================
   Footer (basic)
=================================== */
.site-footer {
  text-align: center;
  font-size: 0.9rem;
  color: var(--page-muted);
  padding: 32px 16px;
  border-top: 1px solid var(--page-border);
  margin-top: 60px;
}

/* ================================
   Reduced Motion
=================================== */
@media (prefers-reduced-motion: reduce) {
  .desktop-header .nav-menu a {
    transition: none;
  }
  .typing-slogan {
    animation: none;
  }
}

/* ================================
   Dark Mode
=================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --hdr-bg: #17171a;
    --hdr-ink: #e8e8e8;
    --hdr-link: #e8e8e8;
    --hdr-link-hover: #bdbdbd;
    --hdr-border: #2a2a2e;
    --hdr-pill: #1f2025;
    --page-bg: #17171a;
    --page-ink: #e8e8e8;
    --page-muted: #bdbdbd;
    --page-border: #2a2a2e;
  }
  .hamburger span {
    background: #e8e8e8;
  }
  .mobile-menu {
    background: #1b1c20;
    border-color: #2a2a2e;
  }
  .mobile-menu a {
    color: #e8e8e8;
  }
  .mobile-menu li {
    border-color: #2a2a2e;
  }

  .sidebar {
    background: #1b1c20;
    border-right-color: #2a2a2e;
  }
  .content-area {
    color: var(--page-ink);
  }
}
