/* apple-system.polish.css
 * Cross-cutting refinements: print, reduced motion, forced colors,
 * selection, scrollbar, skip link, autofill, placeholder, details,
 * text rendering, iOS safe area.
 */

/* 1. Print stylesheet */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .al-hero {
        background: none !important;
        color: #000 !important;
        padding: 24pt 0 !important;
    }

    .al-hero h1 {
        font-size: 22pt;
    }

    .al-hero p {
        font-size: 12pt;
    }

    .al-button,
    .al-stickybar,
    nav,
    header,
    footer,
    .no-print {
        display: none !important;
    }

    .al-surface,
    .al-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .al-section {
        padding-block: 12pt !important;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #555;
    }

    table {
        break-inside: auto;
    }

    tr {
        break-inside: avoid;
        break-after: auto;
    }

    .al-chip {
        border: 1px solid #999;
        background: #fff !important;
        color: #000 !important;
    }
}

/* 2. Reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }

    .al-fade-in,
    .al-reveal,
    .al-pulse {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* 3. Forced colors (Windows High Contrast) */
@media (forced-colors: active) {

    .al-button,
    .al-chip,
    .al-card,
    .al-surface {
        border: 1px solid CanvasText;
        forced-color-adjust: none;
    }

    .al-button--primary {
        background: Highlight;
        color: HighlightText;
    }

    .al-link-chevron,
    .al-button--ghost,
    .al-button--quiet {
        color: LinkText;
    }

    :focus-visible {
        outline: 2px solid Highlight !important;
        outline-offset: 2px;
    }
}

/* 4. Selection colors */
::selection {
    background: color-mix(in srgb, var(--accent-500) 22%, transparent);
    color: var(--ink-900);
}

::-moz-selection {
    background: color-mix(in srgb, var(--accent-500) 22%, transparent);
    color: var(--ink-900);
}

/* 5. Subtle scrollbar (Firefox) */
html {
    scrollbar-color: var(--ink-300) transparent;
    scrollbar-width: thin;
}

/* 6. Skip link (keyboard a11y) */
.al-skip-link {
    position: fixed;
    top: -100px;
    left: 16px;
    z-index: 9999;
    padding: 10px 18px;
    background: var(--ink-900);
    color: var(--ink-000);
    border-radius: 12px;
    font: 600 14px/1.2 var(--font-text);
    text-decoration: none;
    transition: top var(--dur-2, .18s) var(--ease-out);
}

.al-skip-link:focus,
.al-skip-link:focus-visible {
    top: 16px;
    outline: 2px solid var(--accent-500);
    outline-offset: 2px;
}

/* 7. Autofill polish */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--ink-900);
    -webkit-box-shadow: 0 0 0px 1000px var(--ink-000) inset;
    transition: background-color 9999s ease-in-out 0s;
    caret-color: var(--ink-900);
}

/* 8. Placeholder */
input::placeholder,
textarea::placeholder {
    color: var(--ink-400);
    font-style: normal;
    opacity: 1;
}

/* 9. Details/summary polish */
details>summary {
    cursor: pointer;
    list-style: none;
}

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

details[open]>summary {
    margin-bottom: 8px;
}

/* 10. Text rendering */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* 11. iOS safe area */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}