/* ==========================================================================
   Base (#258): typography, reset, accessibility, utility classes and the
   type scale guards. Loaded on every page, after tokens.css.
   ========================================================================== */

/* ==========================================================================
   2. TYPOGRAPHY & FONTS
   ========================================================================== */

/* The parent sets `* { font-family: 'Open Sans' }`, which beats inheritance on
   every element, so a body-only rule never reached most text (issue #138).
   Same selector, loaded later: --font-primary is now the one switch. */
* {
    font-family: var(--font-primary);
}

body {
    font-family: var(--font-primary);
    font-size: var(--fs-base);
    line-height: 1.7;
    color: var(--light-gray);
    background: var(--primary-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* Prevent horizontal scroll on mobile */
    max-width: 100%; /* Override parent theme 2000px cap */
    width: 100%;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
    color: var(--champagne);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(var(--fs-3xl), 5vw, var(--fs-5xl));
    color: var(--champagne);
}

h2 {
    font-size: clamp(var(--fs-3xl), 4vw, var(--fs-4xl));
    color: var(--off-white);
}

h3 {
    font-size: clamp(var(--fs-2xl), 3vw, var(--fs-3xl));
    color: var(--off-white);
}

h4 {
    font-size: clamp(var(--fs-xl), 2.5vw, var(--fs-2xl));
    font-weight: 600;
    color: var(--off-white);
}

h5 {
    font-size: clamp(var(--fs-lg), 2vw, var(--fs-2xl));
    font-weight: 600;
}

h6 {
    font-size: clamp(var(--fs-md), 1.5vw, var(--fs-xl));
    font-weight: 600;
}

/* Paragraphs & Links */
p {
    margin-bottom: var(--spacing-sm);
    color: var(--light-gray);
}

a {
    color: var(--plum-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--champagne);
}

/* Lead paragraph - larger intro text */
.lead,
.bodybox > p:first-of-type {
    font-size: clamp(var(--fs-md), 2vw, var(--fs-lg));
    line-height: 1.8;
    color: var(--light-gray);
}

/* ==========================================================================
   3. BASE RESET & UNIVERSAL STYLES
   ========================================================================== */

/* Smooth scroll for anchor links */
html {
    scroll-behavior: smooth;
    background-color: var(--primary-bg);
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul {
    list-style: none;
}

/* --------------------------------------------------------------------------
   3.1 Accessibility - Skip to Content Link
   -------------------------------------------------------------------------- */

.skip-to-content {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gold);
    color: var(--black-rich);
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    z-index: 10000;
    text-decoration: none;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
    outline: 3px solid var(--champagne);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3.2 Accessibility - Focus Styles
   -------------------------------------------------------------------------- */

/* Visible focus ring for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove default outline since we're using focus-visible */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader only text */
.screen-reader-text,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   13. UTILITY CLASSES
   ========================================================================== */

/* --------------------------------------------------------------------------
   13.1 Float & Text Alignment
   -------------------------------------------------------------------------- */

.clear {
    clear: both;
}

.text-center {
    text-align: center;
}

.l {
    float: left;
}

.r {
    float: right;
}

/* .screen-reader-text — defined in section 3.2 (not duplicated here) */

/* --------------------------------------------------------------------------
   13.2 Modern Responsive Spacing - Replaces clear* divs
   -------------------------------------------------------------------------- */

/* Vertical Spacing - Bottom Margin */
.mb-5,
.spacing-5 { 
    margin-bottom: clamp(5px, 0.5vw, 8px) !important; 
}

.mb-10,
.spacing-10 { 
    margin-bottom: clamp(10px, 1vw, 15px) !important; 
}

.mb-15,
.spacing-15 { 
    margin-bottom: clamp(12px, 1.5vw, 20px) !important; 
}

.mb-20,
.spacing-20 { 
    margin-bottom: clamp(15px, 2vw, 25px) !important; 
}

.mb-30,
.spacing-30 { 
    margin-bottom: clamp(20px, 3vw, 40px) !important; 
}

.mb-40,
.spacing-40 { 
    margin-bottom: clamp(25px, 4vw, 50px) !important; 
}

.mb-50,
.spacing-50 { 
    margin-bottom: clamp(30px, 5vw, 60px) !important; 
}

/* Top Spacing */
.mt-10 { 
    margin-top: clamp(10px, 1vw, 15px) !important; 
}

.mt-20 { 
    margin-top: clamp(15px, 2vw, 25px) !important; 
}

.mt-30 { 
    margin-top: clamp(20px, 3vw, 40px) !important; 
}

/* Padding Utilities */
.p-10 { 
    padding: 10px !important; 
}

.p-20 { 
    padding: 20px !important; 
}

.p-30 { 
    padding: 30px !important; 
}

.py-10 { 
    padding-top: 10px !important; 
    padding-bottom: 10px !important; 
}

.py-20 { 
    padding-top: 20px !important; 
    padding-bottom: 20px !important; 
}

.px-10 { 
    padding-left: 10px !important; 
    padding-right: 10px !important; 
}

.px-20 { 
    padding-left: 20px !important; 
    padding-right: 20px !important; 
}

/* Gap for Flex/Grid Containers */
.gap-10 { 
    gap: 10px !important; 
}

.gap-20 { 
    gap: 20px !important; 
}

.gap-30 { 
    gap: 30px !important; 
}

@media (max-width: 768px) {
    /* Mobile spacing adjustments */
    .spacing-30,
    .mb-30 {
        margin-bottom: 15px !important;
    }
    
    .spacing-40,
    .mb-40 {
        margin-bottom: 20px !important;
    }
    
}

@media (max-width: 480px) {
    .spacing-20,
    .mb-20 {
        margin-bottom: 10px !important;
    }
    
    .spacing-30,
    .mb-30 {
        margin-bottom: 12px !important;
    }
    
}

/* --------------------------------------------------------------------------
   Type scale guards (#141)
   -------------------------------------------------------------------------- */

/* UA "smaller" would render 12.5px off the 15px body - keep it on the scale. */
small {
    font-size: var(--fs-xs);
}

/* iOS Safari zooms the page when a focused field is under 16px. More specific
   form rules above set 15px, so this has to win outright on phones. */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="file"]),
    select,
    textarea {
        font-size: var(--fs-md) !important;
    }
}
