/* ============================================================
   LAYOUT — nav shell, auth shell, page containers, sections
   ============================================================ */

/* ── Site header / top nav ────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--nav-height);
  background: var(--color-dark);
  border-bottom: 3px solid var(--color-primary);
  box-shadow: var(--shadow-md);
}

.nav-container {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo {
  width: 36px;
  height: 36px;
}

.nav-brand-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-inverse);
  letter-spacing: -0.02em;
}

/* .nav-menu wraps links + actions so the mobile dropdown is one panel.
   Scope link styles to .site-header — nav.css also defines .nav-link
   for the app sidebar and both files load together in base_app.html. */
.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex: 1;
  min-width: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.site-header .nav-link {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: rgba(255,255,255,0.75); /* alpha wash of --color-text-inverse */
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}

.site-header .nav-link:hover,
.site-header .nav-link--active {
  color: var(--color-text-inverse);
  background: rgba(255,255,255,0.1); /* alpha wash of --color-text-inverse */
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-full);
  color: rgba(255,255,255,0.75); /* alpha wash of --color-text-inverse */
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.theme-toggle:hover {
  color: var(--color-text-inverse);
  background: rgba(255,255,255,0.1); /* alpha wash of --color-text-inverse */
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: flex; }

/* Label only shows inside the mobile dropdown, where a bare 36px icon
   would float unanchored in a column of full-width rows. */
.theme-toggle__label { display: none; }

/* Book Now lives in the header bar at every width so the primary CTA
   never hides behind the hamburger. */
.nav-cta { flex-shrink: 0; }

.nav-hamburger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text-inverse);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

.nav-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: calc(var(--z-nav) - 1);
}

.nav-backdrop[hidden] { display: none; }

body.nav-open { overflow: hidden; }

/* Mobile nav — breaks at 1000px (not 768px) because the authenticated
   header (5 links + actions) overflows a 70px row well before 768px. */
@media (max-width: 1000px) {
  .nav-container {
    gap: var(--space-3);
    padding: 0 var(--space-4);
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    background: var(--color-dark);
    padding: var(--space-4);
    border-bottom: 3px solid var(--color-primary);
    box-shadow: var(--shadow-lg);
    max-height: calc(100dvh - var(--nav-height));
    overflow-y: auto;
  }

  .nav-menu.is-open { display: flex; }

  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
  }

  .site-header .nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
  }

  .nav-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid rgba(255,255,255,0.12); /* alpha wash of --color-text-inverse */
  }

  .nav-actions .btn { min-height: 44px; }

  .nav-signout-form { display: flex; }
  .nav-signout-form .btn { flex: 1; }

  .theme-toggle {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 500;
  }

  .theme-toggle__label { display: inline; }

  .nav-cta { margin-left: auto; }
  .nav-hamburger { display: flex; }
}

@media (max-width: 400px) {
  .nav-brand-name { font-size: var(--text-base); }
}

/* ── Main content area ────────────────────────────────────── */
.site-main {
  min-height: calc(100vh - var(--nav-height) - 280px);
}

/* ── Container ────────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container--narrow {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ── Sections ─────────────────────────────────────────────── */
.section {
  padding: var(--space-20) 0;
}

.section--alt {
  background: var(--color-surface-alt);
}

.section--cta {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.section--cta h2,
.section--cta p {
  color: var(--color-text-inverse);
}

.section-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: var(--space-3);
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--space-12);
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--color-dark) 0%, var(--color-primary-dark) 60%, var(--color-primary) 100%);
  color: var(--color-text-inverse);
  padding: var(--space-20) var(--space-6) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
}

.hero-content {
  flex: 0 1 520px;
  min-width: 0;
  padding-bottom: var(--space-6);
  text-align: center;
}

.hero-visual {
  flex: 0 0 380px;
  max-width: 380px;
  align-self: flex-end;
}

.hero-phone {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 32px rgba(16, 24, 32, 0.30)); /* alpha wash of --color-gunmetal #101820 */
}

.hero-title {
  font-size: var(--text-5xl);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: var(--space-5);
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: var(--text-xl);
  opacity: 0.85;
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.hero-ctas {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-8);
}

.hero-trust {
  display: flex;
  gap: var(--space-6);
  justify-content: center;
  font-size: var(--text-sm);
  opacity: 0.8;
  flex-wrap: wrap;
}

@media (max-width: 1000px) {
  .hero {
    flex-direction: column;
    padding: var(--space-10) var(--space-6) 0;
    gap: var(--space-6);
    align-items: center;
  }
  .hero-visual {
    order: -1;
    flex: 0 0 auto;
    max-width: 340px;
    width: 100%;
    margin-inline: auto;
  }
  .hero-content {
    flex: none;
  }
  .hero-title { font-size: var(--text-4xl); }
}

@media (max-width: 768px) {
  .hero {
    padding: var(--space-6) var(--space-4) 0;
    gap: var(--space-4);
  }
  .hero-visual { max-width: 280px; }
}

@media (max-width: 500px) {
  .hero {
    padding: var(--space-4) var(--space-4) 0;
    gap: var(--space-3);
  }
  .hero-visual { max-width: 240px; }
  .hero-title { font-size: var(--text-3xl); }
  .hero-subtitle { font-size: var(--text-base); }
  .hero-ctas { flex-direction: column; align-items: center; }
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--color-dark);
  color: rgba(255,255,255,0.7); /* alpha wash of --color-text-inverse */
  padding-top: var(--space-12);
}

.footer-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-12);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-12);
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.footer-brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-inverse);
  font-size: var(--text-xl);
  font-weight: 700;
  text-decoration: none;
}

.footer-logo { width: 32px; height: 32px; }

.footer-brand p {
  font-size: var(--text-sm);
  line-height: 1.6;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-col h4 {
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.footer-col a {
  color: rgba(255,255,255,0.6); /* alpha wash of --color-text-inverse */
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-col a:hover { color: var(--color-text-inverse); }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1); /* alpha wash of --color-text-inverse */
  padding: var(--space-4) var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.4); /* alpha wash of --color-text-inverse */
}

@media (max-width: 768px) {
  .footer-container { grid-template-columns: 1fr; }
  .footer-links { grid-template-columns: repeat(2, 1fr); }
  .hero-title { font-size: var(--text-2xl); }
}

/* ── Flash messages ───────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(480px, calc(100vw - 2rem));
}

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideDown 200ms ease;
}

.flash--success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.flash--error   { background: var(--color-error-bg);   color: var(--color-error);   border: 1px solid var(--color-error-border); }
.flash--info    { background: var(--color-info-bg);    color: var(--color-info);    border: 1px solid var(--color-info-border); }
.flash--warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }

.flash__close {
  font-size: var(--text-lg);
  opacity: 0.6;
  flex-shrink: 0;
}

.flash__close:hover { opacity: 1; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page header (inner pages) ────────────────────────────── */
.page-header {
  background: var(--color-dark);
  color: var(--color-text-inverse);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.page-header h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
}

.page-header p {
  font-size: var(--text-lg);
  opacity: 0.75;
  margin-top: var(--space-2);
}

/* Booking pages render inside the dashboard shell for signed-in users
   (docs/templates.md) — the dark full-bleed hero banner is a public-marketing
   convention, not a dashboard one (see templates/dashboard/index.html), so
   neutralize it there instead of duplicating markup per template. */
.is-authed .page-header {
  background: none;
  color: var(--color-text);
  text-align: left;
  padding: 0 0 var(--space-6);
}

.is-authed .page-header p {
  color: var(--color-text-muted);
  opacity: 1;
}

@media (max-width: 599px) {
  .page-header {
    padding: var(--space-8) var(--space-4);
  }

  .page-header h1 { font-size: var(--text-3xl); }

  .section { padding: var(--space-10) 0; }
}

/* ── Error pages (404/429/500) ─────────────────────────────── */
.error-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-20) var(--space-6);
}

.error-page__code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--color-border-dark);
  line-height: 1;
  margin-bottom: var(--space-4);
}

.error-page__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
}

/* ── Legal / static content pages (terms, privacy, help) ───── */
.legal-page {
  padding-top: var(--space-12);
  padding-bottom: var(--space-20);
}

/* ── Master app window ────────────────────────────────────────── */
/* Viewport-locked: #workspace scrolls internally so the sidebar rail
   (including the avatar/settings footer) stays visible on long pages. */
#program {
  display: flex;
  height: 100dvh;
}

#workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

#workspace::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
  background-clip: padding-box;
}

#workspace::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

.app-main {
  flex: 1;
  padding: var(--space-8) var(--space-6);
  max-width: 1200px;
  width: 100%;
  margin-inline: auto;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.app-footer nav {
  display: flex;
  gap: var(--space-4);
}

.app-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
}

.app-footer a:hover { color: var(--color-primary-text); }

@media (max-width: 699px) {
  .app-main {
    padding: var(--space-4) var(--space-4) calc(var(--mobile-menubar-height) + var(--space-8));
  }
  .app-footer { display: none; }
}

/* Flash stack (used in base_app.html) */
.flash-stack {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(480px, calc(100vw - 2rem));
}
