/*
|--------------------------------------------------------------------------
| ToolVerse - Common Foundation
|--------------------------------------------------------------------------
| Global styles ONLY:
| - Design tokens
| - Safe reset
| - Base document typography
| - Shared container
| - Accessibility utilities
|
| IMPORTANT:
| Page, section and calculator-specific design must stay in its own CSS file.
|--------------------------------------------------------------------------
*/

:root {
    --tv-color-bg: #f7f9fc;
    --tv-color-surface: #ffffff;
    --tv-color-surface-soft: #f0f4fa;

    --tv-color-dark: #0b1220;
    --tv-color-heading: #111827;
    --tv-color-text: #344054;
    --tv-color-muted: #667085;

    --tv-color-primary: #635bff;
    --tv-color-primary-dark: #5048e5;
    --tv-color-primary-soft: #eeedff;

    --tv-color-accent: #00a884;
    --tv-color-accent-soft: #e7f8f4;

    --tv-color-border: #e5e9f0;
    --tv-color-border-strong: #d6dce6;

    --tv-color-success: #067647;
    --tv-color-danger: #d92d20;
    --tv-color-warning: #b54708;

    --tv-shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
    --tv-shadow-sm: 0 4px 14px rgba(16, 24, 40, 0.06);
    --tv-shadow-md: 0 14px 40px rgba(16, 24, 40, 0.08);
    --tv-shadow-lg: 0 24px 70px rgba(16, 24, 40, 0.12);

    --tv-radius-sm: 10px;
    --tv-radius-md: 16px;
    --tv-radius-lg: 24px;
    --tv-radius-xl: 32px;
    --tv-radius-pill: 999px;

    --tv-container-width: 1240px;
    --tv-page-gutter: 24px;
    --tv-header-height: 82px;

    --tv-font:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    --tv-transition-fast: 160ms ease;
    --tv-transition-normal: 260ms ease;
}


/* ==========================================================================
   Safe Reset
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    min-width: 320px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    min-width: 320px;
    min-height: 100vh;
    background: var(--tv-color-bg);
    color: var(--tv-color-text);
    font-family: var(--tv-font);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.tv-menu-open {
    overflow: hidden;
}

main {
    display: block;
}

img,
picture,
svg,
video,
canvas {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

button,
input,
select,
textarea {
    margin: 0;
    font: inherit;
}

button {
    border: 0;
}

button:not(:disabled) {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

a {
    color: inherit;
    text-decoration: none;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
}

ul,
ol {
    margin-top: 0;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

::selection {
    background: var(--tv-color-primary);
    color: #ffffff;
}


/* ==========================================================================
   Shared Container
   ========================================================================== */

.tv-container {
    width: min(
        calc(100% - (var(--tv-page-gutter) * 2)),
        var(--tv-container-width)
    );
    margin-inline: auto;
}


/* ==========================================================================
   Accessibility
   ========================================================================== */

.tv-skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 9999;
    padding: 11px 16px;
    border-radius: var(--tv-radius-sm);
    background: var(--tv-color-dark);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    box-shadow: var(--tv-shadow-md);
    transform: translateY(-160%);
    transition: transform var(--tv-transition-fast);
}

.tv-skip-link:focus {
    transform: translateY(0);
}

.tv-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(99, 91, 255, 0.32);
    outline-offset: 3px;
}


/* ==========================================================================
   Responsive Foundation
   ========================================================================== */

@media (max-width: 1024px) {
    :root {
        --tv-page-gutter: 22px;
    }
}

@media (max-width: 768px) {
    :root {
        --tv-page-gutter: 18px;
        --tv-header-height: 72px;
    }
}

@media (max-width: 480px) {
    :root {
        --tv-page-gutter: 16px;
    }
}


/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}