/*
 * Base Styles
 *
 * Core styles for body, navigation, buttons, forms, footer, and common elements.
 * Mobile-first: base rules target phones, min-width queries scale up.
 */

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-family);
    font-weight: var(--font-weight-normal);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1 0 auto;
}

h1, h2, h3, h4, h5, .heading {
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.01em;
    line-height: 1.15;
}

h1 {
    font-size: clamp(1.75rem, 6.5vw, 2.75rem);
}

h2 {
    font-size: clamp(1.5rem, 5.5vw, 2.25rem);
}

a {
    color: var(--color-link);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--color-primary-dark);
}

/* Keyboard focus (WCAG 2.4.7): one clear outline on everything you can tab to. Blue on light
 * backgrounds, yellow inside the blue top bar, hero and footer (--focus-ring is switched there).
 * It is an outline, not a box-shadow, so it also shows in Windows High Contrast mode.
 * Don't remove it or make it fainter, and keep it away from overflow: hidden edges that would cut it off. */
:root {
    --focus-ring: var(--color-focus-ring);
}

.site-nav,
.site-footer,
.hero-section,
.skip-link {
    --focus-ring: var(--color-focus-ring-on-dark);
}

:root :focus-visible,
:root .btn:focus-visible,
:root .form-control:focus,
:root .form-select:focus {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Spots the page moves focus to itself (the main area, a hint or a note) are not controls: no outline */
:root [tabindex="-1"]:focus {
    outline: none;
}

/* "Skip to main content": hidden until a keyboard user tabs to it (Bootstrap's visually-hidden-focusable) */
.skip-link:focus {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2000;
    padding: 0.6rem 1rem;
    background: var(--color-accent);
    color: var(--color-primary);
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-bold);
    border: 2px solid var(--color-primary);
    border-radius: var(--btn-border-radius);
    text-decoration: none;
}

/* Less motion for people who ask their device for it (spinners, slide-ins, smooth scrolling) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Navigation */
nav.site-nav {
    background-color: var(--color-primary);
    padding: 0.6rem 0;
}

.site-nav .container {
    padding-left: 1rem;
    padding-right: 1rem;
    /* Same bar height on every page, whether or not the Start / Make postcards
       button is shown (it's hidden inside the postcard steps) */
    min-height: 40px;
}

@media (min-width: 992px) {
    .site-nav .container {
        min-height: 48px;
    }
}

.site-nav .navbar-brand {
    display: flex;
    align-items: center;
    margin-right: auto;
    padding: 0;
}

/* Logo (P.S. Vote main logo, public/images/brand/; favicon is the heart-only stamp) */
.brand-logo {
    display: block;
    height: 44px;
    width: auto;
}

@media (min-width: 992px) {
    .brand-logo {
        height: 52px;
    }
}

.site-nav .nav-link {
    color: var(--color-text-inverse);
    font-weight: var(--font-weight-semibold);
}

.site-nav .nav-link:hover,
.site-nav .nav-link:focus {
    color: var(--color-accent);
}

/* The yellow outline above replaces Bootstrap's faint blue glow */
.site-nav .nav-link:focus-visible {
    box-shadow: none;
}

.site-nav .nav-start {
    margin-right: 0.5rem;
    padding: 0.25rem 0.9rem;
    min-height: 40px;
    font-size: 0.95rem;
}

/* The top bar buttons (Start on phones, Make postcards on wide screens) stay flat: no bottom edge */
.site-nav .btn-primary {
    --btn-edge-size: 0px;
}

@media (max-width: 379.98px) {
    .site-nav .nav-start {
        padding: 0.25rem 0.7rem;
        margin-right: 0.4rem;
    }
}

.site-nav .navbar-toggler {
    border: 2px solid var(--color-text-inverse);
    padding: 0.25rem 0.45rem;
    font-size: 1.1rem;
}

.site-nav .navbar-toggler:focus {
    box-shadow: none;
}

.site-nav .navbar-toggler-icon {
    background-image: none;
    background-color: var(--color-text-inverse);
    -webkit-mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='white' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='white' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    mask-repeat: no-repeat;
    -webkit-mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-position: center;
}

/* Windows High Contrast mode repaints backgrounds, which would hide the three lines drawn above */
@media (forced-colors: active) {
    .site-nav .navbar-toggler-icon {
        forced-color-adjust: none;
        background-color: ButtonText;
    }
}

@media (max-width: 991.98px) {
    .site-nav .navbar-collapse .navbar-nav {
        padding: 0.75rem 0 0.25rem;
    }
}

/* Modals */
.modal-content {
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-card);
}

/* Buttons (flat: no blurred shadows)
 * Primary = Emoji Yellow with blue text and a blue outline, plus a hard edge along the bottom
 * (--btn-edge-size) so it reads as pressable. The edge is blue on light backgrounds and darker
 * yellow on blue ones; pressing a button pushes it down onto its edge.
 * Secondary = white with a blue outline.
 */
.btn {
    border-radius: var(--btn-border-radius);
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-bold);
    border-width: 2px;
    min-height: 48px;
    padding: 0.6rem 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    max-width: 100%;   /* long labels wrap instead of running off the screen with large text */
    transition: background-color 0.15s ease;
    /* Bootstrap's faint focus glow is replaced by the outline under "Keyboard focus" */
    --bs-btn-focus-box-shadow: none;
}

.btn-sm {
    min-height: 36px;
    padding: 0.25rem 0.9rem;
}

.btn-primary,
.btn-success {
    --bs-btn-bg: var(--color-accent);
    --bs-btn-color: var(--color-primary);
    --bs-btn-border-color: var(--color-primary);
    --bs-btn-hover-bg: var(--color-accent-hover);
    --bs-btn-hover-color: var(--color-primary);
    --bs-btn-hover-border-color: var(--color-primary);
    --bs-btn-active-bg: var(--color-accent-hover);
    --bs-btn-active-color: var(--color-primary);
    --bs-btn-active-border-color: var(--color-primary);
    --bs-btn-active-shadow: none;
    --bs-btn-focus-shadow-rgb: 25, 3, 158;
    --bs-btn-disabled-bg: var(--color-accent);
    --bs-btn-disabled-color: var(--color-primary);
    --bs-btn-disabled-border-color: var(--color-primary);
    --btn-edge: var(--color-primary);
    box-shadow: 0 var(--btn-edge-size) 0 var(--btn-edge);
}

/* Keep the edge when focused (Bootstrap's :focus-visible rule would replace it) */
.btn-primary:focus-visible,
.btn-success:focus-visible {
    box-shadow: 0 var(--btn-edge-size) 0 var(--btn-edge);
}

.btn-primary:not(.disabled):not(:disabled):not([aria-disabled="true"]):active,
.btn-success:not(.disabled):not(:disabled):not([aria-disabled="true"]):active {
    box-shadow: none;
    transform: translateY(var(--btn-edge-size));
}

.btn-primary:disabled,
.btn-success:disabled {
    box-shadow: none;
}

.btn-secondary,
.btn-info,
.btn-secondary-dark,
.btn-danger,
.btn-outline-danger {
    --bs-btn-bg: var(--color-bg);
    --bs-btn-color: var(--color-primary);
    --bs-btn-border-color: var(--color-primary);
    --bs-btn-hover-bg: var(--brand-pale-pink);
    --bs-btn-hover-color: var(--color-primary);
    --bs-btn-hover-border-color: var(--color-primary);
    --bs-btn-active-bg: var(--brand-soft-pink);
    --bs-btn-active-color: var(--color-primary);
    --bs-btn-active-border-color: var(--color-primary);
    --bs-btn-active-shadow: none;
    --bs-btn-focus-shadow-rgb: 25, 3, 158;
    --bs-btn-disabled-bg: var(--color-bg);
    --bs-btn-disabled-color: var(--color-primary);
    --bs-btn-disabled-border-color: var(--color-primary);
}

/* Button on a blue background: the yellow fill carries it, so the outline matches the fill */
.btn-on-dark {
    --bs-btn-border-color: var(--color-accent);
    --bs-btn-hover-border-color: var(--color-accent-hover);
    --bs-btn-active-border-color: var(--color-accent-hover);
    --btn-edge: var(--brand-yellow-edge);
}

.btn-xl {
    font-size: 1.2rem;
    min-height: 58px;
    padding: 0.75rem 2rem;
}

/* Forms */
.form-control,
.form-select {
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    min-height: 48px;
    font-size: 1rem; /* 16px keeps iOS from zooming in on focus */
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: none;   /* the outline under "Keyboard focus" shows focus */
}

/* A field with a problem: red border + the message right under it (linked with aria-describedby) */
.form-control[aria-invalid="true"],
.form-select[aria-invalid="true"] {
    border-color: var(--color-error);
}

.field-error {
    margin: 0.4rem 0 0;
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    background: var(--color-error-bg);
    color: var(--color-error);
    font-size: 0.95rem;
    font-weight: var(--font-weight-semibold);
}

.form-label {
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
    margin-bottom: 0.25rem;
}

/* Chips (small rounded labels) */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-chip);
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
    background: var(--color-bg-subtle);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    white-space: nowrap;
}

.chip-accent {
    background: var(--color-accent);
}

/* Chips on a blue background are chat bubbles: soft pink with a tail */
.chip-on-dark {
    position: relative;
    background: var(--brand-soft-pink);
    color: var(--color-primary);
    border: 0;
    border-radius: var(--radius-bubble);
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-bold);
}

.chip-on-dark::after {
    content: "";
    position: absolute;
    left: 0.75rem;
    bottom: -0.45rem;
    border-style: solid;
    border-width: 0.5rem 0.6rem 0 0;
    border-color: var(--brand-soft-pink) transparent transparent transparent;
}

/* Demo notice pill */
.demo-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-chip);
    background: var(--brand-soft-pink);
    color: var(--color-primary);
    font-size: 0.8rem;
    font-weight: var(--font-weight-bold);
    border: 2px solid var(--color-primary);
}

/* Progress bar */
.progress {
    background-color: var(--color-progress-bg);
    border-radius: 20px;
    height: 20px;
    overflow: hidden;
}

.progress-bar {
    background-color: var(--color-primary);
    border-radius: 20px;
}

/* Emphasis text */
.emphasis-text {
    color: var(--color-primary);
}

/* Flash messages */
.alert-success {
    background: var(--color-accent);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    border-radius: 14px;
    font-weight: var(--font-weight-semibold);
}

/* Site footer */
.site-footer {
    flex-shrink: 0;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    padding: 2rem var(--page-gutter) 2.5rem;
    font-size: 0.9rem;
    text-align: center;
}

.site-footer a {
    color: var(--color-text-inverse);
}

.site-footer a:hover {
    color: var(--color-accent);
}

.footer-logo {
    display: block;
    height: 70px;
    width: auto;
    margin: 0 auto 1.25rem;
}

.site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    margin-bottom: 1rem;
    font-weight: var(--font-weight-semibold);
}

.paid-for-box {
    border: 2px solid currentColor;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Intro logo */
.intro-logo {
    width: 160px;
}

/* "Last day" banner under the top bar on every page (deadline_banner_text in base.html.twig). Blue on
   Accessible Tangerine passes AA contrast. */
.deadline-banner {
    background: var(--brand-tangerine);
    color: var(--brand-blue);
    text-align: center;
    padding: 0.6rem 1rem;
    font-size: 0.98rem;
    line-height: 1.35;
}
