/* ==========================================================================
   Artisan Hosting — layout.css
   Page shell: header, dropdown nav, mobile drawer, section rhythm, grids, footer.

   Breakpoint: the nav switches to a drawer below 1024px. The old sheet used
   768px, which was fine for 5 flat links but wraps badly with 7 items and
   4 dropdowns. One breakpoint, used consistently.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Wrappers
   -------------------------------------------------------------------------- */

.container,
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--wrap-pad);
}

/* Structural rhythm inside a section. style/script are excluded so inline
   tags don't open phantom gaps. */
.wrap > *:not(style):not(script) + * { margin-top: clamp(12px, 2vw, 28px); }

main { display: block; min-height: 50vh; }

section { padding-block: var(--section-space); }

/* The old sheet used `section + section { border-top }`, which silently
   breaks the moment a wrapper or a data-include div lands between siblings.
   Explicit class instead. */
.section-divider { border-top: 1px solid var(--border); }

.section-sunken { background: color-mix(in srgb, var(--surface-sunken) 60%, transparent); }

/* --------------------------------------------------------------------------
   Header

   The header is injected at runtime by include.js, so the placeholder div
   reserves its height to stop every page shifting down on load.
   -------------------------------------------------------------------------- */

.header-slot { min-height: var(--header-h); }

header.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
  transition: transform var(--dur) var(--ease);
}

/* Auto-hide on scroll, driven by include.js. Only ever animates transform —
   the translucent background/blur stays constant in both states so the
   header slides away instead of fading. */
header.nav.is-hidden { transform: translateY(-100%); }

:root[data-effects='reduced'] header.nav.is-hidden { transform: none; }

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--maxw);
  margin-inline: auto;
  padding: var(--space-3) var(--wrap-pad);
  min-height: var(--header-h);
}

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

/* Kept deliberately compact: with 7 top-level nav items plus a CTA, a
   300px wordmark is what pushes the desktop nav into wrapping. */
.brand img {
  width: auto;
  height: 36px;
  max-width: min(55vw, 240px);
}

/* --------------------------------------------------------------------------
   Nav — desktop
   -------------------------------------------------------------------------- */

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.95rem;
}

.nav-links a:not(.btn),
.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.nav-links a:not(.btn):hover,
.nav-links a:not(.btn):focus-visible,
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible {
  background: var(--btn-ghost-hover);
  color: var(--text-strong);
}

/* You are here — solid wine underline. */
.nav-links .active {
  position: relative;
  font-weight: 700;
  color: var(--text-strong);
  background: color-mix(in srgb, var(--btn-ghost-hover) 65%, transparent);
}

.nav-links .active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 5px;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--wine);
}

/* You are somewhere in this section — same underline at 45%, and no bold,
   so it never competes with the exact-page state inside an open dropdown. */
.nav-links .section-active {
  position: relative;
  color: var(--text-strong);
}

.nav-links .section-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 5px;
  height: 2px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--wine) 45%, transparent);
}

/* --------------------------------------------------------------------------
   Dropdowns
   -------------------------------------------------------------------------- */

.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-dropdown-toggle { font: inherit; cursor: pointer; }

.dropdown-icon {
  width: 12px;
  height: 12px;
  transition: transform var(--dur-fast) var(--ease);
}

.nav-dropdown.open .dropdown-icon { transform: rotate(180deg); }

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: none;
  flex-direction: column;
  min-width: 220px;
  padding: 8px 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: calc(var(--z-header) + 1);
}

.nav-dropdown-menu a {
  padding: 9px 16px !important;
  border-radius: 0 !important;
  color: var(--text-2);
  white-space: nowrap;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus-visible {
  background: var(--btn-ghost-hover) !important;
  color: var(--text-strong);
}

.nav-dropdown.open .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: flex; }

/* Hover-to-open only where hover is real. On touch, the first tap fires a
   synthetic hover AND a click, and include.js click-toggles — so an
   ungated :hover rule produces an open-then-immediately-close flicker. */
@media (hover: hover) and (pointer: fine) {
  .nav-dropdown:hover .nav-dropdown-menu { display: flex; }
}

/* --------------------------------------------------------------------------
   Hamburger + drawer
   -------------------------------------------------------------------------- */

.hamburger {
  display: none;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-1);
}

.hamburger svg { width: 24px; height: 24px; }

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: color-mix(in srgb, var(--navy) 45%, transparent);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

.nav-scrim.is-visible { opacity: 1; visibility: visible; }

@media (max-width: 1023.98px) {
  .nav-inner { flex-wrap: wrap; }

  .hamburger { display: block; }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .nav-links.open {
    display: flex;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    z-index: var(--z-drawer);
    padding: var(--space-3) var(--wrap-pad) var(--space-5);
    background: color-mix(in srgb, var(--bg) 97%, transparent);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);

    /* 7 items + 4 accordions overflows a short viewport. */
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .nav-links.open > a:not(.btn),
  .nav-links.open .nav-dropdown-toggle {
    width: 100%;
    justify-content: space-between;
    padding: 12px 0;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-links .active::after,
  .nav-links .section-active::after { left: 0; right: auto; width: 22px; bottom: 6px; }

  .nav-dropdown {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  /* Accordion, not popover. */
  .nav-dropdown-menu {
    position: static;
    width: 100%;
    margin: 0 0 var(--space-3);
    padding: 4px 0;
    background: color-mix(in srgb, var(--surface-2) 70%, transparent);
    border-radius: var(--radius-sm);
    box-shadow: none;
  }

  .nav-dropdown-menu a { padding: 11px 14px !important; }

  .nav-links.open .nav-dropdown:not(.open) .nav-dropdown-menu { display: none; }

  .nav-links .btn {
    width: 100%;
    justify-content: center;
    margin-top: var(--space-4);
  }

  .theme-toggle { align-self: flex-start; margin-top: var(--space-3); }
}

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

/* Body scroll lock while the drawer is open, set by include.js. The body is
   pinned `fixed` at its captured scroll offset rather than just given
   `overflow: hidden` — overflow:hidden on the scrolling root un-sticks a
   position:sticky header mid-scroll (it snaps to its in-flow position,
   which is off the top of the viewport), and the drawer is anchored to
   that header, so it went dark-screen-with-no-menu right along with it. */
html.nav-open { overflow: hidden; }

/* No overflow:hidden here — body is header.nav's own parent, and giving a
   sticky element's parent an overflow other than visible makes *it* (not
   the viewport) the sticky containing scrollport. position:fixed alone
   already takes body out of the document scroll. */
body.nav-locked {
  position: fixed;
  left: 0;
  right: 0;
}

/* --------------------------------------------------------------------------
   Grids
   -------------------------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--grid-gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1023.98px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

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

.stack { display: grid; gap: var(--grid-gap); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: var(--space-8);
  padding-block: var(--space-7) var(--space-5);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  color: var(--text-2);
  font-size: 0.94rem;
}

.footer-grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  align-items: start;
}

@media (max-width: 1023.98px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}

.footer-brand img { height: 36px; width: auto; margin-bottom: var(--space-3); }

.footer-col h3 {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--space-3);
}

.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li + li { margin-top: 6px; }

.footer-col a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.footer-col a:hover,
.footer-col a:focus-visible { color: var(--text-strong); border-bottom-color: currentColor; }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.875rem;
}

@media (max-width: 719.98px) {
  .footer-bottom {
    justify-content: center;
    text-align: center;
  }

  .footer-bottom > div,
  .footer-bottom > ul { flex-basis: 100%; }
}

.footer-socials { display: flex; gap: var(--space-2); list-style: none; margin: 0; padding: 0; justify-content: center; }

.footer-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-2);
  transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.footer-socials a:hover,
.footer-socials a:focus-visible {
  transform: translateY(-2px);
  color: var(--text-strong);
  border-color: color-mix(in srgb, var(--sky) 60%, var(--border));
}
