/* ═══════════════════════════════════════════════════════════════
   TOOLVAULT — layout.css
   Navigation, page shells, sidebar, footer, ad slots, responsive.
   ═══════════════════════════════════════════════════════════════ */

/* ── Page shell ── */
.page-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.page-body {
  display: flex;
  flex: 1;
}
.page-main {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem;
}

/* ── Nav ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--bd);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--tx);
  flex-shrink: 0;
}
.nav-logo-text {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-style: italic;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.nav-logo-text strong { font-style: normal; font-weight: 500; color: var(--ac); }
.nav-logo:hover { text-decoration: none; }

.nav-divider { width: 1px; height: 20px; background: var(--bd); }

.nav-tagline {
  font-size: 0.75rem;
  color: var(--tx3);
  font-style: italic;
  white-space: nowrap;
}

/* Nav search (compact, in nav bar) */
.nav-search {
  flex: 1;
  max-width: 380px;
  margin-left: auto;
  position: relative;
}
.nav-search-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  color: var(--tx);
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nav-search-input:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--ac-dim); }
.nav-search-input::placeholder { color: var(--tx3); }
.nav-search-icon {
  position: absolute;
  left: 0.6rem; top: 50%;
  transform: translateY(-50%);
  color: var(--tx3);
  font-size: 0.75rem;
  pointer-events: none;
}

/* Nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}
.nav-link {
  font-size: 0.82rem;
  color: var(--tx2);
  padding: 0.35rem 0.65rem;
  border-radius: calc(var(--r) - 2px);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.nav-link:hover { color: var(--tx); background: var(--bg3); text-decoration: none; }
.nav-link.active { color: var(--ac); background: var(--ac-dim); }

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--r);
  background: var(--bg2);
  border: 1px solid var(--bd);
  color: var(--tx2);
  font-size: 0.82rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.theme-toggle:hover { color: var(--tx); border-color: var(--bd2); }
.theme-toggle-icon { font-size: 0.95rem; }

/* Hamburger (mobile) */
.nav-menu-btn {
  display: none;
  padding: 0.4rem;
  border-radius: var(--r);
  color: var(--tx2);
  font-size: 1.2rem;
  border: 1px solid var(--bd);
  background: var(--bg2);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--bd);
  background: var(--bg2);
  padding: 1.25rem 0;
  /* Sticky within page-body */
  position: sticky;
  top: 60px;
  height: calc(100dvh - 60px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-section { margin-bottom: 1rem; }
.sidebar-label {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.7rem;
  color: var(--ac);
  padding: 0 1.1rem;
  margin-bottom: 0.35rem;
  display: block;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  color: var(--tx2);
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  position: relative;
}
.sidebar-item:hover { color: var(--tx); background: var(--bg3); text-decoration: none; }
.sidebar-item.active {
  color: var(--ac);
  background: var(--ac-dim);
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--ac);
  border-radius: 0 2px 2px 0;
}
.sidebar-item-icon { font-size: 0.85rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-count {
  margin-left: auto;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  color: var(--tx3);
  background: var(--bg3);
  border: 1px solid var(--bd);
  padding: 1px 5px;
  border-radius: 3px;
}
.sidebar-item.active .sidebar-count { border-color: var(--ac-glow); }

/* ── Right rail (optional) ── */
.rail {
  width: 160px;
  flex-shrink: 0;
  border-left: 1px solid var(--bd);
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 60px;
  height: calc(100dvh - 60px);
  overflow-y: auto;
}
.rail-section-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tx3);
  margin-bottom: 0.4rem;
}
.rail-item {
  font-size: 0.75rem;
  color: var(--tx2);
  padding: 0.3rem 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  transition: color 0.12s;
}
.rail-item:hover { color: var(--ac); text-decoration: none; }
.rail-item::before { content: '→'; font-size: 0.6rem; opacity: 0.4; }

/* ── Ad slots ── */
.ad-slot {
  border: 1px dashed var(--bd2);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
}
.ad-slot::before {
  content: attr(data-size);
  font-family: 'DM Mono', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tx3);
  opacity: 0.5;
}
/* Standard sizes */
.ad-banner      { height: 90px; width: 100%; }    /* 728×90 leaderboard */
.ad-rectangle   { height: 250px; width: 100%; }   /* 300×250 rectangle */
.ad-sidebar     { height: 140px; }                 /* 160×140 sidebar small */
.ad-tall        { height: 280px; }                 /* 160×280 sidebar tall */
/* Hide ad labels in production (add .ad-live class when real ads load) */
.ad-slot.ad-live::before { display: none; }

/* ── Page header (tool pages) ── */
.page-header {
  margin-bottom: 1.5rem;
}
.page-header-inner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.page-header-icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}
.page-header-info {}
.page-header-title {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.page-header-desc {
  font-size: 0.85rem;
  color: var(--tx2);
  margin-top: 0.25rem;
}
.page-header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.page-header-meta .badge { }

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--tx3);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--tx3); text-decoration: none; }
.breadcrumb a:hover { color: var(--tx2); }
.breadcrumb-sep { color: var(--bd2); }
.breadcrumb-cur { color: var(--tx2); }
/* Support aria-based breadcrumbs (no explicit class on sep/cur) */
.breadcrumb > span[aria-hidden] { color: var(--bd2); }
.breadcrumb > [aria-current="page"] { color: var(--tx2); }

/* ── Tool workspace ── */
.tool-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.tool-workspace.stacked { grid-template-columns: 1fr; }

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--bd);
  background: var(--bg);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-brand {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--tx2);
}
.footer-links {
  display: flex;
  gap: 1.25rem;
}
.footer-link {
  font-size: 0.78rem;
  color: var(--tx3);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--tx2); }
.footer-copy {
  font-size: 0.72rem;
  color: var(--tx3);
}

/* ── Mobile drawer (sidebar) ── */
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
}
.drawer-overlay.open { display: block; }

/* ═══════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════ */

/* Tablet: hide rail */
@media (max-width: 1100px) {
  .rail { display: none; }
}

/* Tablet: collapse sidebar */
@media (max-width: 860px) {
  .nav-tagline { display: none; }
  .nav-search  { max-width: 260px; }
  .sidebar {
    position: fixed;
    left: -240px;
    top: 60px;
    width: 240px;
    height: calc(100dvh - 60px);
    z-index: 501;
    transition: left 0.25s ease;
    border-right: 1px solid var(--bd);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .nav-menu-btn { display: flex; }
  .nav-links { display: none; }
  .page-main { padding: 1.25rem 1rem; }
}

/* Mobile */
@media (max-width: 600px) {
  .nav { padding: 0 0.85rem; gap: 0.5rem; }
  .nav-search { max-width: none; flex: 1; }
  .nav-logo-text { font-size: 1rem; }
  /* Hide theme toggle label on small screens — icon only */
  .theme-toggle [data-theme-label] { display: none; }
  .theme-toggle { padding: 0.35rem 0.5rem; gap: 0; }

  .tool-workspace {
    grid-template-columns: 1fr;
  }

  .page-main { padding: 1rem 0.85rem; }

  .footer {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #toast-container { left: 0.75rem; right: 0.75rem; bottom: 1rem; }
  .toast { max-width: none; }

  .ad-banner { height: 60px; }
  .ad-wrap { padding: 0.5rem 0.85rem; }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 380px) {
  .nav-logo-text { font-size: 0.9rem; }
  .nav-divider { display: none; }
}

/* ── Utilities for tools ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

.section { margin-bottom: 1.5rem; }
.section-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--tx3);
  margin-bottom: 0.65rem;
}
