/*
 * design-system.css — adtechsanto.fun
 * Single source of truth for palette, typography, and accessibility tokens.
 * Loaded globally via head_common.php. All site-wide variables live here.
 *
 * Palette (Premium Dark):
 *   Background  #09090e  (deep obsidian)
 *   Body text   #e6e6f0  (soft white)
 *   Secondary   #8888a8  (muted slate)
 *   Accent      #f97316  (orange — brand primary)
 */

/* ─── 1. DESIGN TOKENS ───────────────────────────────────────────────────── */
:root {
    /* Palette */
    --ds-bg:              #09090e;
    --ds-bg-alt:          #0f0f1a;
    --ds-bg-subtle:       #16162a;
    --ds-text:            #e6e6f0;
    --ds-text-secondary:  #8888a8;
    --ds-text-strong:     #ffffff;
    --ds-accent:          #f97316;
    --ds-accent-hover:    #ea580c;
    --ds-accent-light:    rgba(249, 115, 22, 0.15);
    --ds-border:          rgba(255, 255, 255, 0.08);
    --ds-border-strong:   rgba(255, 255, 255, 0.16);

    /* Site variables consumed by home.css, header-footer.css, etc. */
    --site-bg:            #09090e;
    --site-bg-alt:        #0f0f1a;
    --site-text:          #e6e6f0;
    --site-text-strong:   #ffffff;
    --site-text-muted:    #8888a8;
    --site-border:        rgba(255, 255, 255, 0.08);
    --site-accent:        #f97316;

    /* Typography scale — spec: h1=32px h2=24px h3=20px body≥16px */
    --ds-h1:       2rem;      /* 32px */
    --ds-h2:       1.5rem;    /* 24px */
    --ds-h3:       1.25rem;   /* 20px */
    --ds-body:     1rem;      /* 16px */
    --ds-small:    0.875rem;  /* 14px */
    --ds-lh-body:    1.7;
    --ds-lh-heading: 1.3;

    /* Spacing */
    --ds-radius-sm:  6px;
    --ds-radius-md:  12px;
    --ds-radius-lg:  20px;
    --ds-radius-xl:  28px;

    /* Shadows */
    --ds-shadow-sm: 0 1px 4px rgba(0,0,0,0.40);
    --ds-shadow-md: 0 4px 16px rgba(0,0,0,0.50);
    --ds-shadow-lg: 0 12px 40px rgba(0,0,0,0.55);

    /* Transitions */
    --ds-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── 2. LIGHT-THEME EXPLICIT OVERRIDE ──────────────────────────────────── */
[data-theme="light"],
.theme-light {
    --ds-bg:              #f8f8fc;
    --ds-bg-alt:          #ffffff;
    --ds-bg-subtle:       #f0f0f8;
    --ds-text:            #12121e;
    --ds-text-secondary:  #5a5a7a;
    --ds-text-strong:     #000000;
    --ds-border:          rgba(10, 10, 30, 0.10);
    --ds-border-strong:   rgba(10, 10, 30, 0.20);
    --site-bg:            #f8f8fc;
    --site-bg-alt:        #ffffff;
    --site-text:          #12121e;
    --site-text-strong:   #000000;
    --site-text-muted:    #5a5a7a;
    --site-border:        rgba(10, 10, 30, 0.10);
    --site-accent:        #f97316;
    color-scheme: light;
}

/* ─── 3. GLOBAL TYPOGRAPHY ──────────────────────────────────────────────── */
h1 {
    font-size: var(--ds-h1);
    line-height: var(--ds-lh-heading);
    font-weight: 700;
}
h2 {
    font-size: var(--ds-h2);
    line-height: var(--ds-lh-heading);
    font-weight: 700;
}
h3 {
    font-size: var(--ds-h3);
    line-height: var(--ds-lh-heading);
    font-weight: 600;
}
body {
    font-size: var(--ds-body);
    line-height: var(--ds-lh-body);
}

/* ─── 4. ACCESSIBILITY — WCAG AA FOCUS STYLES ───────────────────────────── */
:focus-visible {
    outline: 3px solid var(--ds-accent);
    outline-offset: 3px;
    border-radius: var(--ds-radius-sm);
}

/* Remove outline only when truly not needed (mouse clicks) */
:focus:not(:focus-visible) {
    outline: none;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    background: var(--ds-accent);
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 0 0 var(--ds-radius-sm) var(--ds-radius-sm);
    font-weight: 700;
    text-decoration: none;
    transition: top var(--ds-transition);
}
.skip-link:focus {
    top: 0;
}

/* ─── 5. BUTTONS ─────────────────────────────────────────────────────────── */
.btn-solid,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;        /* WCAG 2.5.5 touch target */
    padding: 0.55rem 1.25rem;
    border-radius: var(--ds-radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--ds-transition), border-color var(--ds-transition), transform var(--ds-transition);
    border: 2px solid transparent;
}
.btn-solid {
    background: var(--ds-accent);
    color: #ffffff;
    border-color: var(--ds-accent);
}
.btn-solid:hover {
    background: var(--ds-accent-hover);
    border-color: var(--ds-accent-hover);
    transform: translateY(-1px);
    color: #ffffff;
}
.btn-ghost {
    background: transparent;
    color: var(--ds-text);
    border-color: var(--ds-border-strong);
}
.btn-ghost:hover {
    border-color: var(--ds-accent);
    background: var(--ds-accent-light);
    transform: translateY(-1px);
}

/* ─── 6. IMAGE HELPERS ───────────────────────────────────────────────────── */
img {
    max-width: 100%;
    height: auto;
    display: block;
}
.ds-img-hero {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: var(--ds-radius-lg);
}
.ds-img-card {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--ds-radius-md) var(--ds-radius-md) 0 0;
}
figcaption {
    font-size: var(--ds-small);
    color: var(--ds-text-secondary);
    margin-top: 0.5rem;
    text-align: center;
    line-height: 1.5;
}

/* ─── 7. CARD BASE ───────────────────────────────────────────────────────── */
.ds-card {
    background: var(--ds-bg-alt);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--ds-transition), transform var(--ds-transition);
}
.ds-card:hover {
    box-shadow: var(--ds-shadow-md);
    transform: translateY(-2px);
}

/* ─── 8. RESPONSIVE CONTAINERS ──────────────────────────────────────────── */
.ds-container {
    width: min(1200px, calc(100% - 2rem));
    margin-inline: auto;
}
.ds-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}
.ds-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .ds-grid-2,
    .ds-grid-3 {
        grid-template-columns: 1fr;
    }
}
@media (min-width: 768px) and (max-width: 1024px) {
    .ds-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ─── 9. THEME CARD & SECTION OVERRIDES ─────────────────────────────────── */

/* Default (dark) card styles */
.home-card,
.ds-card {
    background: var(--ds-bg-alt);
    border-color: var(--ds-border);
}

/* Light theme card overrides */
[data-theme="light"] .home-card,
[data-theme="light"] .ds-card {
    background: #ffffff;
    border-color: rgba(10, 10, 30, 0.10);
}

/* Light home background */
[data-theme="light"] .au-home {
    background: linear-gradient(180deg, #f8f8fc 0%, #f0f0f8 100%);
}

/* Topic tags — dark default */
.topic-map-tag {
    background: rgba(249, 115, 22, 0.15);
    border-color: rgba(249, 115, 22, 0.35);
    color: #fdba74;
}

/* Topic tags — light mode */
[data-theme="light"] .topic-map-tag {
    background: rgba(249, 115, 22, 0.10);
    border-color: rgba(249, 115, 22, 0.30);
    color: #7c2d12;
}

/* ─── 10. DIAGRAM CAPTION ────────────────────────────────────────────────── */
.ds-diagram-wrap {
    margin: 1.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ds-diagram-caption {
    font-size: var(--ds-small);
    color: var(--ds-text-secondary);
    text-align: center;
    margin-top: 0.5rem;
    font-style: italic;
}

/* ─── 11. PERFORMANCE — CONTENT VISIBILITY ───────────────────────────────── */
.ds-below-fold {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* ─── 12. MOBILE-FIRST RESPONSIVE LAYER ─────────────────────────────────── */
/* Stops horizontal overflow anywhere on the page */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, svg, video, canvas, iframe {
    max-width: 100%;
    height: auto;
}

/* Any fixed-size table / code block becomes scrollable instead of pushing */
.ds-scroll-x,
pre, table {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent iOS auto-zoom on focused inputs */
input, select, textarea {
    font-size: 16px;
}

/* ── Tablet (≤ 1024px) ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .home-hero .hero-simple,
    .hub-hero-card { padding: 1.75rem; }
}

/* ── Phone-landscape / small tablet (≤ 768px) ─────────────────────────── */
@media (max-width: 768px) {
    :root {
        --ds-h1: 1.625rem;   /* 26px */
        --ds-h2: 1.375rem;   /* 22px */
        --ds-h3: 1.125rem;   /* 18px */
    }

    .home-hero .hero-simple,
    .hub-hero-card,
    .home-card { padding: 1.25rem; }

    /* Hero images — shorter so content above the fold stays visible */
    .home-hero figure img,
    .hub-hero-card figure img,
    .blog-article-page figure img { height: 160px !important; }

    /* Buttons stack and go full width */
    .button-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }
    .button-row .btn-solid,
    .button-row .btn-ghost {
        width: 100%;
        margin-left: 0 !important;
    }

    /* Tables wrap in a scrollable shell */
    table { display: block; }
}

/* ── Small phone (≤ 560px) ────────────────────────────────────────────── */
@media (max-width: 560px) {
    :root {
        --ds-h1: 1.5rem;     /* 24px */
        --ds-h2: 1.25rem;    /* 20px */
        --ds-h3: 1.05rem;    /* ~17px */
    }

    .home-hero .hero-simple,
    .hub-hero-card,
    .home-card { padding: 1rem; }

    .home-hero figure img,
    .hub-hero-card figure img,
    .blog-article-page figure img { height: 140px !important; }

    /* Prevent long unbroken tokens (URLs, code) from overflowing */
    p, li, a, span, code, h1, h2, h3 { word-wrap: break-word; overflow-wrap: anywhere; }

    /* Tighter section spacing so content above the fold fits a phone */
    .home-section { padding-block: 1.5rem; }
}

/* ── Reduced motion — honour user preference ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
