/**
 * assets/css/layout.css
 * Step 15.8: this file was missing from the live server entirely (404) —
 * every <head> across the project links it, and several comments elsewhere
 * (components.css's header/sidebar notes) describe rules that were
 * supposed to live here, but the file itself was never actually present.
 * That's the real root cause behind everything reported this session on
 * both mobile AND desktop: no base font/reset, the sidebar rendering as a
 * plain bulleted list in normal page flow instead of a side column next to
 * the content, and the hero/sections running full-bleed edge-to-edge with
 * no page margins. Rebuilt from scratch here using the existing design
 * tokens in variables.css and the component classes already referenced
 * throughout includes/ and sections/ (.page-wrapper, .sidebar,
 * .main-content), so no PHP/HTML had to change to wire this back up.
 */

/* ---------------------------------------------------------------------------
   BASE / RESET
--------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    margin: 0 0 var(--space-4);
    line-height: var(--lh-tight);
}

p {
    margin: 0 0 var(--space-4);
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--color-primary);
}

ul, ol {
    margin: 0;
    padding: 0;
}

button {
    font-family: inherit;
    cursor: pointer;
    background: none;
    border: none;
}

/* ---------------------------------------------------------------------------
   SITE HEADER — outer spacing/positioning only. The header's internal row
   layout (logo/name/tagline vs. the WhatsApp/hamburger actions) is owned by
   components.css (Step 15.6), not here, so it isn't duplicated below.
--------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-3) var(--space-6);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

@media (max-width: 768px) {
    .site-header {
        padding: var(--space-3) var(--space-4);
    }
}

/* ---------------------------------------------------------------------------
   PAGE WRAPPER — sidebar + main-content grid (desktop/tablet), collapsing
   to a single column on mobile (where the sidebar itself is hidden by
   components.css's Step 15.4 rule in favor of the hamburger menu).
--------------------------------------------------------------------------- */
.page-wrapper {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: start;
    gap: var(--space-6);
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--space-6);
    transition: grid-template-columns var(--transition-base);
}

@media (max-width: 1024px) {
    .page-wrapper {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: var(--space-4);
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        display: block;
        padding: var(--space-4);
    }
}

/* Step 15.11: horizontal collapse. Previously toggling the sidebar only
   shrank `.sidebar__nav`'s own height (a vertical accordion) — the
   `.sidebar` grid column itself stayed a fixed 260px/220px, so the main
   content next to it never actually got any wider. Requested change: the
   sidebar should collapse down to a slim icon rail and the page content
   should expand to fill the freed-up width. `.page-wrapper--sidebar-collapsed`
   is toggled by initSidebarAccordion() (assets/js/main.js) on the same
   `.page-wrapper` that defines the grid, alongside `.sidebar--collapsed` on
   the `<aside>` itself (components.css) which shrinks the rail's own
   padding/toggle layout to match. Higher specificity (two classes) than the
   plain `.page-wrapper` rules above/in the breakpoints, so it wins at every
   width without needing to duplicate it inside each @media block. */
.page-wrapper.page-wrapper--sidebar-collapsed {
    grid-template-columns: 60px minmax(0, 1fr);
}

@media (max-width: 768px) {
    /* Desktop-only feature — sidebar is already hidden below 768px in favor
       of the hamburger `.mobile-menu` panel, so the collapsed rail width
       must never apply there. */
    .page-wrapper.page-wrapper--sidebar-collapsed {
        grid-template-columns: none;
    }
}

.main-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

/* ---------------------------------------------------------------------------
   SIDEBAR — desktop/tablet side column. (Hidden below 768px by
   components.css; the mobile slide-in `.mobile-menu` panel takes over
   there instead.)
--------------------------------------------------------------------------- */
.sidebar {
    position: sticky;
    top: calc(64px + var(--space-4));
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

/* Step 15.8: collapse/expand toggle button, sits above .sidebar__nav.
   Layout only here (matches how .sidebar's own box lives in this file);
   the collapse animation + hover color live in components.css next to the
   rest of the sidebar's visual/interactive rules. */
.sidebar__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    color: var(--color-text);
    cursor: pointer;
}

.sidebar__toggle-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    transition: transform var(--transition-base);
}

.sidebar__nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar__nav a {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-weight: var(--fw-medium);
    font-size: var(--fs-sm);
    text-decoration: none;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar__nav a:hover {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
}

@media (max-width: 1024px) {
    .sidebar {
        top: var(--space-4);
    }
}
