/* ==========================================================================
   Advoke CV — Layout layer
   Page shell: containers, header, navigation, footer, page grids,
   sticky behaviour, mobile drawer, and editor workspace frame.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CONTAINERS
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-base);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--container-narrow); }
.container--text   { max-width: var(--container-text); }
.container--wide   { max-width: var(--container-wide); }
.container--full   { max-width: var(--container-full); }

.container--flush {
  padding-inline: 0;
}

/* --------------------------------------------------------------------------
   2. PAGE SHELL
   -------------------------------------------------------------------------- */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.page__main {
  flex: 1 1 auto;
  padding-top: var(--header-h-mobile);
}

@media (min-width: 768px) {
  .page__main {
    padding-top: var(--header-h-desktop);
  }
}

/* Homepage has a transparent header over the hero */
.page--home .page__main {
  padding-top: 0;
}

/* --------------------------------------------------------------------------
   3. SECTIONS
   -------------------------------------------------------------------------- */
.section {
  padding-block: var(--section-y-md);
}

.section--sm { padding-block: var(--section-y-sm); }
.section--lg { padding-block: var(--section-y-lg); }
.section--none { padding-block: 0; }

.section--sunken {
  background: var(--surface-sunken);
  border-block: 1px solid var(--border-subtle);
}

.section--paper {
  background: var(--surface-raised);
}

.section--dark {
  background: var(--c-navy-900);
  color: var(--c-white);
}

.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4 {
  color: var(--c-white);
}

.section--dark p,
.section--dark li {
  color: rgba(255, 255, 255, 0.82);
}

.section__header {
  max-width: var(--container-text);
  margin-inline: auto;
  text-align: center;
  margin-bottom: var(--sp-8);
}

@media (min-width: 768px) {
  .section__header {
    margin-bottom: var(--sp-10);
  }
}

.section__eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--text-accent);
  margin-bottom: var(--sp-3);
}

.section__title {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tighter);
  margin-bottom: var(--sp-4);
  text-wrap: balance;
}

.section__lead {
  font-size: var(--fs-md);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
  max-width: 42rem;
  margin-inline: auto;
}

/* --------------------------------------------------------------------------
   4. SITE HEADER
   -------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  height: var(--header-h-mobile);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transition:
    background var(--dur-base) var(--ease-standard),
    border-color var(--dur-base) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-standard);
}

@media (min-width: 768px) {
  .site-header {
    height: var(--header-h-desktop);
  }
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
  border-bottom-color: var(--border-default);
}

.site-header--transparent {
  background: transparent;
  border-bottom-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.site-header--transparent.is-scrolled {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom-color: var(--border-subtle);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: 100%;
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* --------------------------------------------------------------------------
   5. BRAND
   -------------------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  flex: none;
  transition: opacity var(--dur-fast) var(--ease-standard);
}

.brand:hover {
  opacity: 0.85;
  text-decoration: none;
}

.brand:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.brand__mark {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--c-white);
  box-shadow: var(--shadow-xs);
  flex: none;
}

@media (min-width: 768px) {
  .brand__mark {
    width: 34px;
    height: 34px;
  }
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand__name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  color: inherit;
}

.brand__tag {
  font-size: 0.625rem;
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

@media (max-width: 380px) {
  .brand__tag {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   6. PRIMARY NAVIGATION — desktop
   -------------------------------------------------------------------------- */
.site-nav {
  display: none;
  align-items: center;
  gap: var(--sp-1);
}

@media (min-width: 900px) {
  .site-nav {
    display: flex;
  }
}

.site-nav__link {
  position: relative;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition:
    color var(--dur-fast) var(--ease-standard),
    background var(--dur-fast) var(--ease-standard);
}

.site-nav__link:hover {
  color: var(--text-primary);
  background: var(--interactive-ghost-hover);
  text-decoration: none;
}

.site-nav__link[aria-current="page"] {
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
}

.site-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: -2px;
  height: 2px;
  background: var(--interactive-accent);
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   7. HEADER ACTIONS
   -------------------------------------------------------------------------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
}

@media (min-width: 768px) {
  .header-actions {
    gap: var(--sp-3);
  }
}

/* --------------------------------------------------------------------------
   8. MOBILE MENU BUTTON
   -------------------------------------------------------------------------- */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  transition:
    background var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard);
}

.nav-toggle:hover {
  background: var(--interactive-ghost-hover);
  border-color: var(--border-subtle);
}

.nav-toggle:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.nav-toggle svg {
  width: 22px;
  height: 22px;
}

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   9. MOBILE DRAWER
   -------------------------------------------------------------------------- */
.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: none;
}

.mobile-drawer.is-open {
  display: block;
}

.mobile-drawer__scrim {
  position: absolute;
  inset: 0;
  background: var(--surface-overlay);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-standard);
  animation: advoke-fade-in var(--dur-base) var(--ease-decelerate) forwards;
}

.mobile-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(88vw, 360px);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  animation: drawer-slide-in var(--dur-slow) var(--ease-emphasized) forwards;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@keyframes drawer-slide-in {
  to { transform: translateX(0); }
}

.mobile-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--surface-raised);
  z-index: 1;
}

.mobile-drawer__nav {
  display: flex;
  flex-direction: column;
  padding: var(--sp-3);
  gap: var(--sp-1);
}

.mobile-drawer__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-standard);
}

.mobile-drawer__link:hover,
.mobile-drawer__link:focus-visible {
  background: var(--interactive-ghost-hover);
  text-decoration: none;
}

.mobile-drawer__link[aria-current="page"] {
  background: var(--interactive-accent-soft);
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
}

.mobile-drawer__link svg {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--text-tertiary);
}

.mobile-drawer__link[aria-current="page"] svg {
  color: var(--interactive-accent);
}

.mobile-drawer__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-3) var(--sp-5);
}

.mobile-drawer__footer {
  margin-top: auto;
  padding: var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* --------------------------------------------------------------------------
   10. SITE FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--c-navy-950);
  color: rgba(255, 255, 255, 0.78);
  padding-block: var(--sp-12) var(--sp-8);
  margin-top: auto;
}

@media (min-width: 768px) {
  .site-footer {
    padding-block: var(--sp-16) var(--sp-10);
  }
}

.site-footer a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--c-white);
  text-decoration: underline;
}

.site-footer__top {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-8);
  margin-bottom: var(--sp-10);
}

@media (min-width: 640px) {
  .site-footer__top {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .site-footer__top {
    grid-template-columns: 1.4fr repeat(3, 1fr);
    gap: var(--sp-10);
  }
}

.site-footer__brand {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  max-width: 26rem;
}

.site-footer__brand .brand {
  color: var(--c-white);
}

.site-footer__brand .brand__tag {
  color: rgba(255, 255, 255, 0.5);
}

.site-footer__brand .brand__mark {
  background: var(--c-white);
}

.site-footer__desc {
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: rgba(255, 255, 255, 0.65);
}

.site-footer__col-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--c-white);
  margin-bottom: var(--sp-4);
}

.site-footer__list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
}

.site-footer__list li + li {
  margin-top: 0;
}

.site-footer__bottom {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-top: var(--sp-6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.55);
}

@media (min-width: 768px) {
  .site-footer__bottom {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  list-style: none;
  padding: 0;
}

.site-footer__legal li + li {
  margin-top: 0;
}

/* --------------------------------------------------------------------------
   11. GENERIC RESPONSIVE GRIDS
   -------------------------------------------------------------------------- */
.grid {
  display: grid;
  gap: var(--sp-6);
}

.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: 1fr; }

@media (min-width: 640px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.grid--gap-sm { gap: var(--sp-4); }
.grid--gap-lg { gap: var(--sp-8); }

/* --------------------------------------------------------------------------
   12. TWO-COLUMN CONTENT LAYOUT
   -------------------------------------------------------------------------- */
.layout-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-8);
}

@media (min-width: 900px) {
  .layout-split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: var(--sp-10);
  }
}

.layout-split--reverse > :first-child {
  order: 2;
}

@media (min-width: 900px) {
  .layout-split--reverse {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  }
  .layout-split--reverse > :first-child {
    order: 1;
  }
}

/* --------------------------------------------------------------------------
   13. STICKY SIDEBAR (guides / examples TOC)
   -------------------------------------------------------------------------- */
.sticky-sidebar {
  position: relative;
}

@media (min-width: 1024px) {
  .sticky-sidebar__inner {
    position: sticky;
    top: calc(var(--header-h-desktop) + var(--sp-6));
    max-height: calc(100vh - var(--header-h-desktop) - var(--sp-12));
    overflow-y: auto;
  }
}

/* --------------------------------------------------------------------------
   14. EDITOR WORKSPACE FRAME
   -------------------------------------------------------------------------- */
.editor-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface-sunken);
}

.editor-shell__header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--sp-3) var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.editor-shell__body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

@media (min-width: 1024px) {
  .editor-shell__body {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    height: calc(100vh - var(--header-h-desktop));
    height: calc(100dvh - var(--header-h-desktop));
  }
}

.editor-shell__panel {
  background: var(--surface-raised);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 1023px) {
  .editor-shell__panel {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
}

.editor-shell__panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-4);
}

@media (min-width: 768px) {
  .editor-shell__panel-scroll {
    padding: var(--sp-6);
  }
}

.editor-shell__preview {
  background:
    linear-gradient(180deg, var(--c-neutral-100) 0%, var(--c-neutral-150) 100%);
  padding: var(--sp-4);
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

@media (min-width: 768px) {
  .editor-shell__preview {
    padding: var(--sp-8);
  }
}

/* --------------------------------------------------------------------------
   15. MOBILE EDITOR TAB BAR
   -------------------------------------------------------------------------- */
.editor-tabbar {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: var(--surface-raised);
  border-top: 1px solid var(--border-subtle);
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  height: var(--mobile-tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.editor-tabbar__btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.6875rem;
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  background: none;
  border: none;
  padding: var(--sp-2);
  transition: color var(--dur-fast) var(--ease-standard);
}

.editor-tabbar__btn[aria-selected="true"] {
  color: var(--interactive-accent);
}

.editor-tabbar__btn svg {
  width: 20px;
  height: 20px;
}

@media (min-width: 1024px) {
  .editor-tabbar {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   16. GLOBAL ERROR / STATUS REGIONS
   -------------------------------------------------------------------------- */
.app-error-banner {
  background: var(--c-red-50);
  border-bottom: 1px solid var(--c-red-500);
  color: var(--text-danger);
  padding: var(--sp-3) var(--gutter);
  font-size: var(--fs-sm);
  text-align: center;
  display: none;
}

.app-error-banner.is-visible {
  display: block;
}

/* --------------------------------------------------------------------------
   17. SAFE AREA INSETS (iOS notch / Android gesture nav)
   -------------------------------------------------------------------------- */
.site-header,
.site-footer,
.editor-shell__header {
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}