/**
 * STA Platform v3 — Custom Styles
 * 
 * Most styling is handled by Tailwind utility classes.
 * This file is for things Tailwind can't do: animations,
 * third-party component overrides, and print styles.
 */

/* ================================================================= */
/* Base                                                               */
/* ================================================================= */

/* Smooth scrolling site-wide */
html {
    scroll-behavior: smooth;
}

/* Better focus styles for keyboard navigation */
:focus-visible {
    outline: 2px solid #C5A548;
    outline-offset: 2px;
}

/* Prevent layout shift from scrollbar */
html {
    overflow-y: scroll;
}

/* Dark-mode UA hint: tells browsers to render scrollbars, form controls,
   and other UA chrome in dark variants when html.dark is set. */
html.dark {
    color-scheme: dark;
}

/* ================================================================= */
/* Rich-text content (.prose)                                         */
/* ================================================================= */
/* The Tailwind Typography plugin is NOT part of this project's build, so
   Preflight strips all browser defaults and `prose` is inert on its own.
   These rules replicate the Typography prose-sm preset so headings,
   lists, spacing and inline chrome render correctly.

   Still true after the 2026-08-26 switch from the in-browser CDN script
   to prebuilt CSS: tailwind.config.js declares no `plugins`, and the
   built sheet contains zero `prose` selectors. Re-check with
   `grep -c prose public/inc/css/tailwind.css` before assuming otherwise
   — if that ever returns non-zero, this block is duplicating the plugin
   and should go. Consumed by helpdesk article bodies and ticket bodies. */

/* --- Spacing & typography (prose-sm equivalent) --- */
.prose {
    font-size: 0.875rem;
    line-height: 1.7142857;
}
.prose > * + * {
    margin-top: 1.1428571em;
}
.prose p {
    margin-top: 1.1428571em;
    margin-bottom: 1.1428571em;
}
.prose h1 {
    font-size: 1.7142857em;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 0.8571429em;
}
.prose h2 {
    font-size: 1.2857143em;
    font-weight: 700;
    line-height: 1.3333333;
    margin-top: 1.5714286em;
    margin-bottom: 0.5714286em;
}
.prose h3 {
    font-size: 1.1428571em;
    font-weight: 600;
    line-height: 1.5;
    margin-top: 1.4285714em;
    margin-bottom: 0.4285714em;
}
.prose h4 {
    font-weight: 600;
    line-height: 1.5;
    margin-top: 1.2857143em;
    margin-bottom: 0.2857143em;
}
.prose h2 + *,
.prose h3 + *,
.prose h4 + * {
    margin-top: 0;
}

/* --- Links --- */
.prose a {
    color: #1a1a2e;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
}
.prose a:hover {
    color: #C5A548;
}

/* --- Bold / emphasis --- */
.prose strong {
    font-weight: 700;
}

/* --- Lists --- */
.prose ul {
    list-style-type: disc;
    padding-left: 1.5714286em;
    margin-top: 1.1428571em;
    margin-bottom: 1.1428571em;
}
.prose ol {
    list-style-type: decimal;
    padding-left: 1.5714286em;
    margin-top: 1.1428571em;
    margin-bottom: 1.1428571em;
}
.prose li {
    margin-top: 0.2857143em;
    margin-bottom: 0.2857143em;
}
.prose ul > li::marker {
    color: #9ca3af;
}
.prose ol > li::marker {
    color: #6b7280;
    font-weight: 400;
}

/* --- Blockquotes --- */
.prose blockquote {
    border-left: 3px solid #e5e7eb;
    padding-left: 1em;
    font-style: italic;
    color: #4b5563;
    margin-top: 1.3333333em;
    margin-bottom: 1.3333333em;
}

/* --- Code --- */
.prose code {
    font-size: 0.8571429em;
    font-weight: 600;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.1428571em 0.3571429em;
    border-radius: 0.25rem;
}
.prose pre {
    font-size: 0.8571429em;
    line-height: 1.6666667;
    background-color: #1f2937;
    color: #f3f4f6;
    border-radius: 0.375rem;
    padding: 0.8571429em 1.1428571em;
    margin-top: 1.7142857em;
    margin-bottom: 1.7142857em;
    overflow-x: auto;
}
.prose pre code {
    font-weight: 400;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

/* --- Horizontal rule --- */
.prose hr {
    border-color: #e5e7eb;
    margin-top: 2.2857143em;
    margin-bottom: 2.2857143em;
}

/* --- Tables --- */
.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8571429em;
    margin-top: 1.7142857em;
    margin-bottom: 1.7142857em;
}
.prose table th {
    font-weight: 600;
    text-align: left;
    padding: 0.5714286em 0.8571429em;
    border-bottom: 2px solid #d1d5db;
}
.prose table td {
    padding: 0.5714286em 0.8571429em;
    border-bottom: 1px solid #e5e7eb;
}

/* --- Images --- */
.prose img {
    margin-top: 1.7142857em;
    margin-bottom: 1.7142857em;
    border-radius: 0.375rem;
}

/* --- Dark-mode overrides --- */
html.dark .prose a {
    color: #C5A548;
}
html.dark .prose a:hover {
    color: #d4b76b;
}
html.dark .prose code {
    background-color: rgba(255, 255, 255, 0.1);
    color: #f3f4f6;
}
html.dark .prose pre {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
html.dark .prose blockquote {
    border-left-color: rgba(255, 255, 255, 0.15);
    color: #d1d5db;
}
html.dark .prose hr {
    border-color: rgba(255, 255, 255, 0.1);
}
html.dark .prose table th {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}
html.dark .prose table td {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
html.dark .prose ul > li::marker {
    color: #6b7280;
}
html.dark .prose ol > li::marker {
    color: #9ca3af;
}

/* ================================================================= */
/* Stat-tile change animation (Help Desk dashboard)                   */
/* ================================================================= */

/*
 * Applied by the `helpdeskStatus` Alpine component when a polled counter
 * moves — see public/inc/js/modules/helpdesk_status.js. The class is only
 * present for ~1.6s, and never on first paint, so it marks a change the
 * user did not already see.
 *
 * The flash is an expanding box-shadow ring rather than a background
 * colour: the tiles carry `bg-white dark:bg-gray-900`, and animating
 * background-color would fight those and end on the wrong colour. A ring
 * layers cleanly over both themes. Brand gold (#C5A548) reads against
 * light and dark alike, and is neutral enough not to imply good/bad —
 * these counters go both directions.
 */
@keyframes hd-stat-ring {
    0%   { box-shadow: 0 0 0 0    rgba(197, 165, 72, 0.85); }
    100% { box-shadow: 0 0 0 12px rgba(197, 165, 72, 0);    }
}

@keyframes hd-stat-bump {
    0%   { transform: scale(1);    }
    30%  { transform: scale(1.18); }
    100% { transform: scale(1);    }
}

.hd-stat-changed {
    animation: hd-stat-ring 1.6s ease-out;
}

.hd-stat-changed .hd-stat-value {
    display: inline-block; /* transform has no effect on inline boxes */
    animation: hd-stat-bump 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/*
 * Reduced motion: keep the notification, drop the movement. The ring
 * fades in place instead of expanding, and the number doesn't scale —
 * the point is still communicated without anything travelling.
 */
@media (prefers-reduced-motion: reduce) {
    @keyframes hd-stat-ring-static {
        0%   { box-shadow: 0 0 0 4px rgba(197, 165, 72, 0.85); }
        100% { box-shadow: 0 0 0 4px rgba(197, 165, 72, 0);    }
    }

    .hd-stat-changed {
        animation: hd-stat-ring-static 1.6s ease-out;
    }

    .hd-stat-changed .hd-stat-value {
        animation: none;
    }
}

/* ================================================================= */
/* Touch targets for mobile                                           */
/* ================================================================= */

/* Ensure minimum tap target size on mobile (44px per Apple HIG) */
@media (pointer: coarse) {
    button,
    a[role="button"],
    input[type="checkbox"],
    input[type="radio"],
    .tap-target {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ================================================================= */
/* Print                                                              */
/* ================================================================= */

@media print {
    nav,
    footer,
    .no-print,
    #sta-toast-container {
        display: none !important;
    }

    main {
        padding-top: 0 !important;
    }

    /* Force light theme for printing — dark backgrounds waste toner. */
    html.dark,
    html.dark body {
        background: white !important;
        color: black !important;
    }

    body {
        background: white;
        font-size: 12pt;
    }
}
