/* ============================================================
   US PREPPERS — UX ENHANCEMENTS (ux.css)
   Loaded AFTER css/hero.min.css in default.hbs so these rules
   win by source order. Directly linked (no gulp build needed).

   Covers:
     1. Nav touch targets (WCAG 44x44) + mobile horizontal-overflow
     2. Reading progress bar
     3. Table of contents
     4. Breadcrumbs
     5. Comments empty-block guard
     6. Contact form
     7. Newsletter validation feedback
     8. Accessibility: focus-visible, ARIA helpers
   ============================================================ */

/* ------------------------------------------------------------
   0. DARK MODE GLOBALS
   ------------------------------------------------------------ */
/* Specificity (0,1,1) beats the :root { --ghost-accent-color } block that
   Ghost injects into <head> AFTER these sheets (0,1,0), so article inline
   links keep dark-mode copper #D4844F (5.89:1) instead of falling back to
   light copper #B86B3C (4.25:1, fails AA). color-scheme also gives native
   form controls / scrollbars a dark UA palette. */
html[data-theme="dark"] {
    color-scheme: dark;
    --ghost-accent-color: #D4844F;
}

/* ------------------------------------------------------------
   1. NAVIGATION TOUCH TARGETS + MOBILE OVERFLOW
   ------------------------------------------------------------ */

/* Belt-and-suspenders: pin the collapsed (hidden) fixed menu/actions
   to the viewport so their nowrap content can never widen the page.
   (Also enforced in hero.css; re-declared here because ux.css loads
   last and owns this concern.) */
@media (max-width: 767px) {
    #gh-navigation .gh-navigation-menu,
    #gh-navigation .gh-navigation-actions {
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .is-open#gh-navigation .gh-navigation-menu,
    .is-open#gh-navigation .gh-navigation-actions {
        overflow: visible;
    }
}

/* 44x44px touch targets on touch devices and small screens.
   Targets the link itself, not its flex parent, so the hit area is real. */
@media (max-width: 767px), (pointer: coarse) {
    #gh-navigation .nav a,
    #gh-navigation .gh-navigation-menu a,
    #gh-navigation .gh-navigation-members a,
    #gh-navigation .gh-navigation-actions > a,
    #gh-navigation .gh-navigation-actions .gh-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        min-width: 44px;
    }

    .gh-burger {
        min-width: 44px;
        min-height: 44px;
    }

    /* keep the search + portal triggers comfortable too */
    #gh-navigation .gh-search,
    #gh-navigation .gh-icon-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ------------------------------------------------------------
   2. READING PROGRESS BAR
   ------------------------------------------------------------ */
.ux-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 4000000; /* above the mobile open-nav (3999999) */
    pointer-events: none;
    background: transparent;
}

.ux-progress-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--color-copper, #b86b3c), var(--color-ember, #e25d33));
    box-shadow: 0 0 6px rgba(184, 107, 60, 0.45);
    transition: width 0.08s linear;
}

/* ------------------------------------------------------------
   3. TABLE OF CONTENTS
   Always-visible compact strip: heading links wrap inline like
   tags (no collapse/expand). A short 1–3 line block that never
   dominates the viewport.
   ------------------------------------------------------------ */
nav.ux-toc {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    margin: 0 auto 28px;
    padding: 12px 18px;
    max-width: 720px;
    background: var(--color-surface-raised, #302b26);
    border: 1px solid var(--color-border, #3d3730);
    border-radius: 12px;
    color: var(--color-text, #e8e0d5);
}

/* The `hidden` attribute sets display:none via the UA sheet, but our
   author `display:flex` above would override it — re-assert it here so
   the TOC stays hidden until ux.js reveals it. */
nav.ux-toc[hidden] {
    display: none;
}

.ux-toc-label {
    flex: 0 0 auto;
    font-family: var(--gh-font-heading, var(--font-body));
    font-size: 1.4rem;
    font-weight: 650;
    line-height: 1.4;
    color: var(--color-text, #e8e0d5);
}

.ux-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ux-toc-list li {
    margin: 0;
}

.ux-toc-list a {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--color-border, #3d3730);
    border-radius: 999px;
    background: rgba(184, 107, 60, 0.10);
    color: var(--color-text-muted, #a89b8c);
    font-size: 1.4rem;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.ux-toc-list a:hover,
.ux-toc-list a:focus-visible {
    color: var(--color-link-hover, #e25d33);
    background: rgba(184, 107, 60, 0.18);
    border-color: var(--color-copper, #b86b3c);
}

/* ------------------------------------------------------------
   4. BREADCRUMBS
   ------------------------------------------------------------ */
.ux-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 1.3rem;
    line-height: 1.5;
    color: var(--color-text-muted, #a89b8c);
}

.ux-breadcrumbs a {
    color: var(--color-text-muted, #a89b8c);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ux-breadcrumbs a:hover,
.ux-breadcrumbs a:focus-visible {
    color: var(--color-copper, #b86b3c);
    text-decoration: underline;
}

.ux-breadcrumbs .ux-breadcrumb-sep {
    color: var(--color-border, #3d3730);
    user-select: none;
}

.ux-breadcrumbs .ux-breadcrumb-current {
    color: var(--color-text, #e8e0d5);
    font-weight: 600;
}

/* ------------------------------------------------------------
   5. COMMENTS EMPTY-BLOCK GUARD
   ------------------------------------------------------------ */
/* When the comments-ui iframe fails to bootstrap (blank srcdoc) the
   widget still reserves a fixed-height iframe. Collapse it so a blank
   widget never leaves a big empty void at the bottom of an article. */
.gh-comments {
    min-height: 0;
}

.gh-comments[data-empty] {
    display: none;
}

/* ------------------------------------------------------------
   6. CONTACT FORM
   ------------------------------------------------------------ */
.ux-contact-form {
    margin-top: 24px;
    padding: 24px;
    background: var(--color-surface-raised, #302b26);
    border: 1px solid var(--color-border, #3d3730);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ux-contact-form .ux-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ux-contact-form label {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-text, #e8e0d5);
}

.ux-contact-form .ux-req {
    color: var(--color-ember, #e25d33);
    font-weight: 550;
}

.ux-contact-form input,
.ux-contact-form textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 1.6rem;
    font-family: inherit;
    color: var(--color-text, #e8e0d5);
    background: var(--color-bg, #1e1b18);
    border: 1px solid var(--color-border, #3d3730);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.ux-contact-form input:focus,
.ux-contact-form textarea:focus {
    outline: none;
    border-color: var(--color-copper, #b86b3c);
}

.ux-contact-form textarea {
    resize: vertical;
    min-height: 120px;
}

.ux-contact-form .gh-button.ux-submit {
    align-self: flex-start;
    min-height: 44px;
    background: var(--color-copper, #b86b3c);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 650;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.ux-contact-form .gh-button.ux-submit:hover {
    /*! #9e5a30 = intentional deep-copper hover (matches nav button hover; no darker token) */
    background: #9e5a30;
    transform: translateY(-1px);
}

.ux-form-feedback {
    min-height: 1.4em;
    margin: 0;
    font-size: 1.4rem;
    color: var(--color-ember, #e25d33);
}

.ux-form-feedback.is-success {
    color: var(--color-evergreen, #2d4a3e);
}

[data-theme="dark"] .ux-form-feedback.is-success {
    /*! #7fb08e = intentional dark-mode success green (lighter sage for AA on dark surfaces; no success token) */
    color: #7fb08e;
}

.ux-contact-note {
    font-size: 1.4rem;
    color: var(--color-text-muted, #a89b8c);
}

.ux-contact-note a {
    color: var(--color-copper, #b86b3c);
}

/* ------------------------------------------------------------
   7. NEWSLETTER VALIDATION FEEDBACK
   ------------------------------------------------------------ */
.gh-form [data-members-error]:empty {
    display: none;
}

.gh-form [data-members-error] {
    display: block;
    margin: 8px 0 0;
    font-size: 1.3rem;
    color: var(--color-ember, #e25d33);
}

.gh-form .gh-form-input[aria-invalid="true"] {
    border-color: var(--color-ember, #e25d33);
}

/* ------------------------------------------------------------
   8. ACCESSIBILITY: FOCUS-VISIBLE
   ------------------------------------------------------------ */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--color-ember, #e25d33);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Respect users who want no motion */
@media (prefers-reduced-motion: reduce) {
    .ux-progress-bar-fill,
    .ux-toc-list a,
    .ux-breadcrumbs a {
        transition: none;
    }
}

/* ------------------------------------------------------------
   9. FOOTER + CATEGORY TILE TAP TARGETS (WCAG 44px)
   ------------------------------------------------------------ */
/* Footer column nav links (Categories / Company / Legal) are ~19px
   tall text links — give them a real 44px tap target. */
.gh-footer-col ul li a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* Category tiles ("Field Manual Index") — guarantee a 44px+ hit area.
   (Already flex + padded, so this is belt-and-suspenders; inline-flex
   blockifies to flex inside the grid and changes nothing visually.) */
.gh-category-card-v2 {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
