/*
 * AHSC Theme — Main CSS
 * Critical path: Layout, Typography, Header, Footer, Core Components
 */

/* ─── Reset + Custom Properties ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --color-primary:       #1a73e8;
    --color-primary-dark:  #1558b0;
    --color-secondary:     #f57c00;
    --color-text:          #1f2937;
    --color-text-muted:    #6b7280;
    --color-bg:            #ffffff;
    --color-bg-alt:        #f9fafb;
    --color-border:        #e5e7eb;
    --color-success:       #16a34a;
    --color-error:         #dc2626;

    --font-sans:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:   ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --text-4xl:  2.25rem;

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;

    --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 12px rgba(0,0,0,.1);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.12);

    --container-max: 1200px;
    --container-px:  1.25rem;

    --header-height: 64px;
    --transition:    200ms ease;
}

/* ─── Base Typography ─────────────────────────────────────────────────────── */
html { font-size: 100%; scroll-behavior: smooth; }

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

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: .5em;
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-text);
}
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

p  { margin-top: 0; margin-bottom: 1rem; }
a  { color: var(--color-primary); text-decoration: underline; }
a:hover { color: var(--color-primary-dark); }

img { max-width: 100%; height: auto; display: block; }
ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.container {
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-px);
    padding-right: var(--container-px);
}

.screen-reader-text {
    clip: rect(1px,1px,1px,1px);
    height: 1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
    word-wrap: normal;
}
.screen-reader-text:focus {
    clip: auto;
    height: auto;
    left: 1rem;
    top: 1rem;
    z-index: 9999;
    background: var(--color-bg);
    padding: .5rem 1rem;
    font-weight: 700;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.btn--primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn--primary:hover, .btn--primary:focus {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
    text-decoration: none;
}
.btn--secondary {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn--secondary:hover {
    background: var(--color-primary);
    color: #fff;
}
.btn--text {
    background: none;
    border-color: transparent;
    color: var(--color-primary);
    padding-left: 0;
    padding-right: 0;
}
.btn--sm { padding: .4rem .85rem; font-size: var(--text-xs); }

/* ─── Site Layout ─────────────────────────────────────────────────────────── */
.site-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.site-main    { flex: 1; padding-top: 2rem; padding-bottom: 4rem; }

/* ─── Header ──────────────────────────────────────────────────────────────── */
.site-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    height: var(--header-height);
}

.site-header__inner {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 1.5rem;
}

.site-header__brand { flex-shrink: 0; }
.site-header__brand a { text-decoration: none; }
.site-header__logo-text {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--color-text);
}
.site-header__tagline {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin: 0;
}

/* Primary Nav */
.site-header__nav { flex: 1; }

.primary-nav__menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: .25rem;
}
.primary-nav__menu li a {
    display: block;
    padding: .4rem .75rem;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.primary-nav__menu li a:hover,
.primary-nav__menu .current-menu-item > a { background: var(--color-bg-alt); color: var(--color-primary); }

.primary-nav__toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .5rem;
}
.primary-nav__hamburger,
.primary-nav__hamburger::before,
.primary-nav__hamburger::after {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    position: relative;
    transition: transform var(--transition);
}
.primary-nav__hamburger::before,
.primary-nav__hamburger::after {
    content: '';
    position: absolute;
}
.primary-nav__hamburger::before { top: -7px; }
.primary-nav__hamburger::after  { top: 7px; }

/* Search */
.search-form {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-bg-alt);
}
.search-form__input {
    border: none;
    background: transparent;
    padding: .4rem .75rem;
    font-size: var(--text-sm);
    outline: none;
    width: 180px;
}
.search-form__submit {
    background: none;
    border: none;
    padding: .4rem .6rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--color-text);
    color: #d1d5db;
    margin-top: auto;
}
.site-footer__widgets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    padding-top: 3rem;
    padding-bottom: 2rem;
}
.site-footer .widget__title { color: #fff; font-size: var(--text-base); margin-bottom: .75rem; }
.site-footer a { color: #d1d5db; text-decoration: none; }
.site-footer a:hover { color: #fff; }

.site-footer__nav { padding: 1rem 0; border-top: 1px solid rgba(255,255,255,.1); }
.footer-nav__menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
}
.footer-nav__menu li a { font-size: var(--text-sm); }

.site-footer__bottom {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 1.25rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 2rem;
    align-items: center;
}
.site-footer__copy,
.site-footer__disclaimer { margin: 0; font-size: var(--text-xs); color: #9ca3af; }

/* ─── Breadcrumbs ─────────────────────────────────────────────────────────── */
.breadcrumbs { margin-bottom: 1rem; }
.breadcrumbs__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.breadcrumbs__link { color: var(--color-primary); }
.breadcrumbs__current { color: var(--color-text-muted); }
.breadcrumbs__separator { color: var(--color-border); user-select: none; }

/* ─── Two-column layout with sidebar ─────────────────────────────────────── */
.calculator-page,
.single-post,
.location-page,
.guest-post-page {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2.5rem;
    align-items: start;
}
.calculator-page__primary,
.single-post__primary,
.location-page__primary,
.guest-post-page__primary { min-width: 0; }

.sidebar { position: sticky; top: calc(var(--header-height) + 1rem); }

/* ─── Entry / Post ────────────────────────────────────────────────────────── */
.entry__header { margin-bottom: 1.5rem; }
.entry__title  { margin-bottom: .5rem; }
.entry__meta   { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: var(--text-sm); color: var(--color-text-muted); }
.entry__thumbnail { margin-bottom: 2rem; border-radius: var(--radius-md); overflow: hidden; }
.entry__content { line-height: 1.8; }

/* ─── Card ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card__thumbnail img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.card__body   { padding: 1.25rem; }
.card__title  { font-size: var(--text-lg); margin-bottom: .5rem; }
.card__title a { color: var(--color-text); text-decoration: none; }
.card__title a:hover { color: var(--color-primary); }
.card__excerpt { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: 1rem; }
.card__footer { display: flex; justify-content: flex-end; }
.card__meta   { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: .5rem; }

/* ─── Ads ─────────────────────────────────────────────────────────────────── */
.ahsc-ad { margin: 1.5rem 0; text-align: center; }
.ahsc-ad-placeholder {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-align: center;
}

.ahsc-mobile-sticky-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    padding: .25rem;
    text-align: center;
    box-shadow: 0 -4px 12px rgba(0,0,0,.1);
}
.ahsc-mobile-sticky-ad__close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .calculator-page,
    .single-post,
    .location-page,
    .guest-post-page {
        grid-template-columns: 1fr;
    }
    .sidebar { position: static; }
}

@media (max-width: 768px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }

    .site-footer__widgets { grid-template-columns: 1fr; }

    .primary-nav__toggle { display: block; }
    .primary-nav__menu {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--color-bg);
        flex-direction: column;
        border-bottom: 1px solid var(--color-border);
        padding: .5rem 1rem;
        box-shadow: var(--shadow-md);
    }
    .primary-nav__menu.is-open { display: flex; }
    .primary-nav__menu li { width: 100%; }
    .search-form__input { width: 130px; }
}
