/* ============================================================
   West Star — shared component styles (extracted from base.html
   so the browser caches them once instead of re-downloading
   ~13 KB of inline CSS on every navigation).
   Cosmic tokens + header/footer/canvas live in cosmic/cosmic.css.
   Page-specific styles stay in each template's extra_css block.
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Justify body paragraphs in content sections (MS Word-style fill). */
section p,
section li,
.card p,
.card-dark p,
article p,
.article-content p {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
}

section .section-subtitle,
section .hero-subtitle,
.footer-bottom p {
    text-align: inherit;
    hyphens: none;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
}

/* ═══════════════ CONTAINER ═══════════════ */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 28px;
}

/* ═══════════════ SECTIONS ═══════════════ */
section { padding: 48px 0; }

.section-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.section-label::before {
    content: '';
    width: 20px;
    height: 1px;
    background: var(--accent);
}

.section-title {
    font-size: clamp(2rem, 3.5vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 16px;
    line-height: 1.15;
}

.section-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 540px;
    line-height: 1.7;
}

/* ═══════════════ BUTTONS ═══════════════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: var(--accent);
    color: white;
    font-family: var(--font);
    font-weight: 600;
    font-size: 15px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.25s ease;
}

.btn-primary:hover {
    background: var(--accent-light);
    color: white;
    box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 1px rgba(52, 211, 153, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-weight: 500;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.25s ease;
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
    background: rgba(255,255,255,0.03);
}

/* ═══════════════ CARDS (shared across pages) ═══════════════ */
.card-dark {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card-dark::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-dark:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.card-dark:hover::before { opacity: 1; }

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 20px;
}

.card-icon.purple { background: var(--accent-glow); color: var(--accent-light); }
.card-icon.green { background: var(--green-glow); color: var(--green); }
.card-icon.orange { background: rgba(245, 158, 11, 0.12); color: var(--orange); }
.card-icon.blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }

.card-dark h3, .card-dark h4 {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}

.card-dark p {
    color: var(--text-secondary);
    font-size: 14.5px;
    line-height: 1.65;
}

/* Tags */
.tag {
    font-family: var(--mono);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.05);
    display: inline-block;
    margin: 2px;
}

/* ═══════════════ PAGE HEADER (for subpages) ═══════════════ */
.page-header {
    padding: 40px 0 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
    pointer-events: none;
}

.page-header .section-title { position: relative; z-index: 2; }
.page-header .section-subtitle { position: relative; z-index: 2; margin: 0 auto; }

/* ═══════════════ GRID UTILITIES ═══════════════ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
/* Let grid items shrink below content min-size so a full-bleed cover image
   (negative margins) can't blow a column out past the viewport on mobile. */
.grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap-gap { display: flex; flex-wrap: wrap; gap: 8px; }

/* ═══════════════ FORM ELEMENTS ═══════════════ */
.form-field {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
}

.form-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-field::placeholder { color: var(--text-muted); }

.form-label {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

textarea.form-field { resize: vertical; min-height: 120px; }

select.form-field { appearance: auto; }

/* ═══════════════ ALERTS ═══════════════ */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: var(--green-glow);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--green);
}

.alert-error, .alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.alert-close {
    float: right;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
}

.alert-close:hover { opacity: 1; }

/* ═══════════════ ANIMATIONS ═══════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    opacity: 0;
    transform: translateY(24px);
    transition: all 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    section { padding: 24px 0; }
    .page-header { padding: 18px 0 24px; }
    .btn-primary, .btn-secondary, button { min-height: 44px; }
}

@media (max-width: 600px) {
    .grid-4 { grid-template-columns: 1fr; }
}
