/**
 * ========================================================
 * RESET.CSS - Modern CSS Reset
 * ========================================================
 *
 * A modern CSS reset that provides a clean, consistent baseline
 * across all browsers while preserving useful defaults.
 *
 * Based on:
 * - Josh Comeau's Custom CSS Reset
 * - Andy Bell's Modern CSS Reset
 * - Normalize.css principles
 *
 * Key Features:
 * - Uses border-box sizing for all elements
 * - Removes default margins
 * - Sets sensible typography defaults
 * - Improves media element handling
 * - Enhances form element consistency
 * - Provides accessibility improvements
 *
 * ========================================================
 */


/* ========================================================
   1. BOX SIZING
   ========================================================
   Use border-box model for more intuitive sizing
   ======================================================== */

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


/* ========================================================
   2. RESET MARGINS & PADDING
   ========================================================
   Remove default spacing for consistent baseline
   ======================================================== */

* {
    margin: 0;
    padding: 0;
}


/* ========================================================
   3. ROOT & DOCUMENT
   ========================================================
   Set up smooth scrolling and text rendering
   ======================================================== */

html {
    /* Enable smooth scrolling (respects user preferences) */
    scroll-behavior: smooth;

    /* Prevent font size inflation on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;

    /* Improve text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Set consistent line height */
    line-height: 1.5;

    /* Prevent iOS tap highlight */
    -webkit-tap-highlight-color: transparent;
}

/* Reduce motion for users who prefer it */
@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;
        scroll-behavior: auto !important;
    }
}


/* ========================================================
   4. BODY DEFAULTS
   ========================================================
   Establish core body styles
   ======================================================== */

body {
    /* Minimum height for sticky footer patterns */
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */

    /* Improve text rendering */
    text-rendering: optimizeSpeed;

    /* Allow percentage heights on children */
    line-height: inherit;
}


/* ========================================================
   5. TYPOGRAPHY RESET
   ========================================================
   Remove built-in font styling
   ======================================================== */

h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
}

p, li, figcaption {
    /* Improve readability with balanced text wrap */
    text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
    /* Prevent orphans in headings */
    text-wrap: balance;
}


/* ========================================================
   6. LISTS
   ========================================================
   Remove default list styling
   ======================================================== */

ul,
ol {
    list-style: none;
}

/* Restore list styles where semantic lists are desired */
ul[role="list"],
ol[role="list"] {
    list-style: revert;
}


/* ========================================================
   7. LINKS
   ========================================================
   Reset anchor styling
   ======================================================== */

a {
    color: inherit;
    text-decoration: inherit;
}

/* Remove the gap between links and other inline elements */
a:not([class]) {
    text-decoration-skip-ink: auto;
}


/* ========================================================
   8. MEDIA ELEMENTS
   ========================================================
   Improve media defaults
   ======================================================== */

img,
picture,
video,
canvas,
svg {
    /* Responsive by default */
    display: block;
    max-width: 100%;
}

img,
picture,
video {
    /* Maintain aspect ratio */
    height: auto;
}

/* Prevent large images from overflowing */
img {
    /* Remove gap below images */
    vertical-align: middle;

    /* Prevent image dragging */
    -webkit-user-drag: none;
    user-select: none;
}

/* Make SVGs inherit color by default */
svg {
    fill: currentColor;
}

svg:not([fill]) {
    fill: currentColor;
}


/* ========================================================
   9. FORM ELEMENTS
   ========================================================
   Normalize form element appearance
   ======================================================== */

button,
input,
select,
textarea {
    /* Inherit font styles from parent */
    font: inherit;
    color: inherit;

    /* Remove default styling */
    background: transparent;
    border: none;

    /* Remove default padding */
    padding: 0;
}

/* Reset button appearance */
button {
    cursor: pointer;
    background: none;
}

/* Remove default button styling */
button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* Improve textarea behavior */
textarea {
    /* Prevent horizontal resize */
    resize: vertical;

    /* Minimum height */
    min-height: 120px;
}

/* Remove spinner from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Remove default search styling */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
}

/* Consistent select appearance */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Remove default fieldset styling */
fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

/* Legend styling */
legend {
    padding: 0;
}

/* Disabled state */
:disabled {
    cursor: not-allowed;
}


/* ========================================================
   10. TABLE RESET
   ========================================================
   Normalize table appearance
   ======================================================== */

table {
    border-collapse: collapse;
    border-spacing: 0;
}

th {
    text-align: inherit;
    font-weight: inherit;
}


/* ========================================================
   11. INTERACTIVE ELEMENTS
   ========================================================
   Reset interactive element defaults
   ======================================================== */

/* Details and Summary */
details > summary {
    cursor: pointer;
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

/* Dialog */
dialog {
    padding: 0;
    border: none;
}

/* Remove default outline (we'll add custom focus styles in base.css) */
:focus {
    outline: none;
}

/* Preserve focus visibility for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--color-primary, #8BA888);
    outline-offset: 2px;
}


/* ========================================================
   12. MISC RESETS
   ========================================================
   Additional element resets
   ======================================================== */

/* Horizontal rule */
hr {
    border: none;
    border-top: 1px solid currentColor;
    opacity: 0.2;
}

/* Abbreviations */
abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

/* Address */
address {
    font-style: inherit;
}

/* Quotes */
blockquote,
q {
    quotes: none;
}

blockquote::before,
blockquote::after,
q::before,
q::after {
    content: '';
}

/* Code elements */
code,
kbd,
samp,
pre {
    font-family: ui-monospace, 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.9em;
}

/* Preformatted text */
pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Subscript and Superscript */
sub,
sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

sup {
    top: -0.5em;
}

sub {
    bottom: -0.25em;
}

/* Small text */
small {
    font-size: 80%;
}

/* Mark/Highlight */
mark {
    background-color: #ff0;
    color: #000;
}

/* Hidden elements */
[hidden] {
    display: none !important;
}

/* Template */
template {
    display: none;
}


/* ========================================================
   13. PRINT RESET
   ========================================================
   Basic print styles for better printing
   ======================================================== */

@media print {
    *,
    *::before,
    *::after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
    }

    abbr[title]::after {
        content: " (" attr(title) ")";
    }

    img {
        page-break-inside: avoid;
    }

    h2, h3 {
        page-break-after: avoid;
    }

    p {
        orphans: 3;
        widows: 3;
    }
}
