/*
 * pgisfun-trip-votes — public styles.
 *
 * Deliberately scoped under .pgisfun-votes and built on custom properties, so
 * the theme keeps ownership of fonts and the plugin only brings layout. No
 * charting library, no icon font, no webfont.
 */

.pgisfun-votes {
    /*
     * Values come from the site's own global styles where they exist, so the
     * plugin inherits the palette rather than restating it. The fallbacks are
     * the current paraglidingisfun.com values, for the admin preview and for
     * any context where the theme's custom properties aren't in scope.
     */
    --pgv-ink: var(--wp--preset--color--contrast, #0a0f33);
    --pgv-base: var(--wp--preset--color--base, #ffffff);
    --pgv-accent: var(--wp--preset--color--accent-3, #4c7ff0);
    --pgv-focus: var(--wp--preset--color--accent-4, #3cc8f0);
    --pgv-highlight: var(--wp--preset--color--accent-5, #f9d94a);

    --pgv-muted: #5b6172;
    --pgv-border: rgba(10, 15, 51, .16);
    --pgv-bg-soft: #f4f5f8;
    --pgv-err: #b42318;
    --pgv-ok: #157347;

    /* The theme has no border-radius anywhere: buttons, inputs and chips are
       square. Only images and cards get the 25px the site uses on its hero. */
    --pgv-radius-lg: 25px;
    --pgv-gap: 20px;
    --pgv-font-sm: var(--wp--preset--font-size--small, .875rem);
    --pgv-font-md: var(--wp--preset--font-size--medium, 1rem);

    box-sizing: border-box;
    max-width: 100%;
}

/*
 * Declared outright rather than as `inherit`: inheriting it depends on an
 * unbroken chain of matching ancestors, and when that chain breaks, form
 * controls fall back to content-box — at which point width:100% plus padding
 * overflows its container by exactly the padding, which is what pushed the
 * suggest form's fields through the right edge of its panel.
 */
.pgisfun-votes,
.pgisfun-votes *,
.pgisfun-votes *::before,
.pgisfun-votes *::after { box-sizing: border-box; }

/* ---------- notices ---------- */

.pgisfun-votes .pgv-notice {
    margin: 0 0 18px;
    padding: 12px 16px;
    background: var(--pgv-bg-soft);
    border-left: 4px solid var(--pgv-muted);
}
.pgisfun-votes .pgv-notice-ok { border-left-color: var(--pgv-ok); }
.pgisfun-votes .pgv-notice-warn { border-left-color: var(--pgv-warn); }

/* ---------- form scaffolding ---------- */

.pgisfun-votes .pgv-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 28px;
}
.pgisfun-votes .pgv-legend {
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0;
    margin: 0 0 6px;
}
.pgisfun-votes .pgv-hint {
    margin: 0 0 16px;
    color: var(--pgv-muted);
    font-size: .95rem;
}
.pgisfun-votes .pgv-row {
    display: flex;
    gap: var(--pgv-gap);
    flex-wrap: wrap;
    margin: 0 0 18px;
}
/* min-width:0 — a flex item defaults to min-width:auto and refuses to shrink
   below its content, which is the other classic way a field escapes its box. */
.pgisfun-votes .pgv-row > .pgv-field { flex: 1 1 240px; min-width: 0; }
.pgisfun-votes .pgv-field { display: block; margin: 0 0 18px; }
.pgisfun-votes .pgv-label {
    display: block;
    font-weight: 600;
    margin: 0 0 6px;
    font-size: .95rem;
}
.pgisfun-votes .pgv-req { color: var(--pgv-err); }
.pgisfun-votes .pgv-help {
    display: block;
    margin-top: 5px;
    font-size: .82rem;
    color: var(--pgv-muted);
}
.pgisfun-votes input[type="text"],
.pgisfun-votes input[type="email"],
.pgisfun-votes input[type="date"],
.pgisfun-votes select,
.pgisfun-votes textarea {
    display: block;
    width: 100%;
    max-width: 30rem;
    padding: .7rem .9rem;
    border: 1px solid var(--pgv-border);
    border-radius: 0;
    background: var(--pgv-base);
    font: inherit;
    font-size: var(--pgv-font-md);
    line-height: 1.4;
    color: inherit;
}
.pgisfun-votes textarea { max-width: 100%; }
.pgisfun-votes input:focus-visible,
.pgisfun-votes select:focus-visible,
.pgisfun-votes textarea:focus-visible {
    outline: 2px solid var(--pgv-focus);
    outline-offset: 2px;
}
.pgisfun-votes textarea { resize: vertical; }
.pgisfun-votes .pgv-field-error input,
.pgisfun-votes .pgv-field-error textarea,
.pgisfun-votes .pgv-field-error select { border-color: var(--pgv-err); }

.pgisfun-votes .pgv-consent {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0 0 22px;
    font-size: .9rem;
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-consent input { margin-top: 4px; flex: none; }

/* The honeypot: off-screen for people, present in the DOM for bots. */
.pgisfun-votes .pgv-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------- course cards ---------- */

.pgisfun-votes .pgv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--pgv-gap);
}
.pgisfun-votes .pgv-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--pgv-border);
    border-radius: var(--pgv-radius-lg);
    overflow: hidden;
    background: #fff;
    transition: box-shadow .15s ease, border-color .15s ease;
}
.pgisfun-votes .pgv-card:hover { box-shadow: 0 6px 22px rgba(16, 24, 40, .09); }
.pgisfun-votes .pgv-card.is-picked {
    border-color: var(--pgv-ink);
    box-shadow: 0 0 0 2px var(--pgv-ink);
}
.pgisfun-votes .pgv-card-media { aspect-ratio: 16 / 9; background: var(--pgv-bg-soft); }
.pgisfun-votes .pgv-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.pgisfun-votes .pgv-card-body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.pgisfun-votes .pgv-card-title {
    margin: 0 0 8px;
    font-size: 1.1rem;
    line-height: 1.3;
}
.pgisfun-votes .pgv-card-meta {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: .82rem;
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-card-meta li::before { content: "· "; }
.pgisfun-votes .pgv-card-meta li:first-child::before { content: none; }
.pgisfun-votes .pgv-card-excerpt {
    margin: 0 0 16px;
    font-size: .92rem;
    line-height: 1.5;
}
.pgisfun-votes .pgv-card-actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.pgisfun-votes .pgv-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
}
.pgisfun-votes .pgv-check input { width: 18px; height: 18px; }
.pgisfun-votes .pgv-more,
.pgisfun-votes .pgv-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: var(--pgv-font-sm);
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}
.pgisfun-votes .pgv-more:hover,
.pgisfun-votes .pgv-link:hover { text-decoration: none; }

/* ---------- chips ---------- */

.pgisfun-votes .pgv-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.pgisfun-votes .pgv-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: .5rem .9rem;
    border: 1px solid var(--pgv-border);
    border-radius: 0;
    cursor: pointer;
    font-size: var(--pgv-font-sm);
    background: var(--pgv-base);
}
.pgisfun-votes .pgv-chip:has(input:checked) {
    border-color: var(--pgv-ink);
    background: var(--pgv-ink);
    color: var(--pgv-base);
}

/* ---------- buttons ---------- */

.pgisfun-votes .pgv-btn {
    /* Mirrors the theme's .wp-element-button: square, contrast fill, 1rem/2.25rem
       padding, brightness+lift on hover, accent-4 focus ring. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 1rem 2.25rem;
    border: 0;
    border-radius: 0;
    background: var(--pgv-ink);
    color: var(--pgv-base);
    font: inherit;
    font-size: var(--pgv-font-md);
    text-decoration: none;
    cursor: pointer;
    transition: filter .2s ease, transform .15s ease;
}
.pgisfun-votes .pgv-btn:hover,
.pgisfun-votes .pgv-btn:focus {
    filter: brightness(.92);
    transform: translateY(-1px);
    color: var(--pgv-base);
}
.pgisfun-votes .pgv-btn:focus-visible {
    outline: 2px solid var(--pgv-focus);
    outline-offset: 2px;
}
.pgisfun-votes .pgv-btn-primary {
    background: var(--pgv-ink);
    color: var(--pgv-base);
}
/* The theme's outline button style. */
.pgisfun-votes .pgv-btn-quiet {
    background: transparent;
    color: var(--pgv-ink);
    box-shadow: inset 0 0 0 2px currentColor;
}
.pgisfun-votes .pgv-btn-quiet:hover,
.pgisfun-votes .pgv-btn-quiet:focus { color: var(--pgv-ink); }
.pgisfun-votes .pgv-btn[disabled] {
    opacity: .55;
    cursor: progress;
    transform: none;
    filter: none;
}

.pgisfun-votes .pgv-submit-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pgisfun-votes .pgv-status { margin: 14px 0 0; font-size: .95rem; }
.pgisfun-votes .pgv-status.is-error { color: var(--pgv-err); }
.pgisfun-votes .pgv-status.is-ok { color: var(--pgv-ok); }

/* ---------- results ---------- */

.pgisfun-votes .pgv-results-head { margin: 0 0 18px; }
.pgisfun-votes .pgv-results-title { margin: 0 0 4px; }
.pgisfun-votes .pgv-results-subtitle { margin: 32px 0 12px; font-size: 1.05rem; }
.pgisfun-votes .pgv-results-total { margin: 0; color: var(--pgv-muted); font-size: .92rem; }

.pgisfun-votes .pgv-bars { display: flex; flex-direction: column; gap: 14px; }
.pgisfun-votes .pgv-bar-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin: 0 0 5px;
}
.pgisfun-votes .pgv-bar-label { font-weight: 600; font-size: .95rem; }
.pgisfun-votes .pgv-bar-sub {
    display: block;
    font-weight: 400;
    font-size: .8rem;
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-bar-value { white-space: nowrap; font-size: .9rem; }
.pgisfun-votes .pgv-bar-pct { color: var(--pgv-muted); margin-left: 6px; }
.pgisfun-votes .pgv-bar-track {
    background: var(--pgv-bg-soft);
    height: 12px;
    overflow: hidden;
}
.pgisfun-votes .pgv-bar-fill {
    height: 100%;
    background: rgba(10, 15, 51, .28);
    transition: width .4s ease;
}
.pgisfun-votes .pgv-bar-lead .pgv-bar-fill { background: var(--pgv-ink); }
.pgisfun-votes .pgv-change { margin: 26px 0 0; font-size: .9rem; }
.pgisfun-votes .pgv-empty { color: var(--pgv-muted); }

/* ---------- modal ---------- */

.pgisfun-votes .pgv-modal[hidden] { display: none; }
.pgisfun-votes .pgv-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.pgisfun-votes .pgv-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, .6);
}
.pgisfun-votes .pgv-modal-panel {
    position: relative;
    background: #fff;
    border-radius: var(--pgv-radius-lg);
    max-width: 720px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.pgisfun-votes .pgv-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, .92);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.pgisfun-votes .pgv-modal-media { aspect-ratio: 16 / 9; background: var(--pgv-bg-soft); }
.pgisfun-votes .pgv-modal-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.pgisfun-votes .pgv-modal-body { padding: 22px 26px 26px; }
.pgisfun-votes .pgv-modal-title { margin: 0 0 10px; }
.pgisfun-votes .pgv-modal-meta { margin-bottom: 18px; }
.pgisfun-votes .pgv-modal-content img { max-width: 100%; height: auto; }
.pgisfun-votes .pgv-modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* Stops the page behind the modal scrolling on iOS. */
body.pgv-modal-open { overflow: hidden; }

/* ---------- suggest ---------- */

.pgisfun-votes .pgv-suggest-details {
    border: 1px solid var(--pgv-border);
    padding: 0 clamp(18px, 4vw, 36px);
    background: var(--pgv-bg-soft);
}

/* Replace the default disclosure triangle with a square +/- that matches the
   rest of the site's hard-edged furniture. */
.pgisfun-votes .pgv-suggest-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: var(--pgv-font-md);
    padding: clamp(16px, 3vw, 22px) 0;
    list-style: none;
}
.pgisfun-votes .pgv-suggest-summary::-webkit-details-marker { display: none; }
.pgisfun-votes .pgv-suggest-summary::before {
    content: "+";
    flex: none;
    width: 1.5em;
    height: 1.5em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pgv-ink);
    font-weight: 400;
    line-height: 1;
}
.pgisfun-votes .pgv-suggest-details[open] .pgv-suggest-summary::before { content: "\2013"; }
.pgisfun-votes .pgv-suggest-summary:focus-visible {
    outline: 2px solid var(--pgv-focus);
    outline-offset: 2px;
}

/*
 * One readable column, one field width. The previous version capped each field
 * differently (title 26rem, textarea 100%, halves in a flex row), which read as
 * ragged even when nothing overflowed.
 */
.pgisfun-votes .pgv-suggest-form {
    /* 32rem inside a panel whose content box is ~36rem leaves real slack, so a
       field cannot graze the panel edge even at an awkward viewport width. */
    max-width: 32rem;
    padding: 0 0 clamp(16px, 3vw, 26px);
}
.pgisfun-votes .pgv-suggest-form .pgv-field { margin: 0 0 16px; }
.pgisfun-votes .pgv-suggest-form .pgv-row {
    display: block;
    margin: 0;
}
.pgisfun-votes .pgv-suggest-form input[type="text"],
.pgisfun-votes .pgv-suggest-form input[type="email"],
.pgisfun-votes .pgv-suggest-form textarea {
    width: 100%;
    max-width: 100%;
}
.pgisfun-votes .pgv-suggest-form textarea { min-height: 7.5rem; }
.pgisfun-votes .pgv-suggest-form .pgv-hint { margin-bottom: 20px; }
.pgisfun-votes .pgv-suggest-form .pgv-consent { margin-bottom: 20px; }

/* ---------- grid headings ---------- */

.pgisfun-votes .pgv-grid-heading { margin: 0 0 16px; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
    .pgisfun-votes .pgv-modal { padding: 0; align-items: flex-end; }
    .pgisfun-votes .pgv-modal-panel {
        max-height: 92vh;
        border-radius: var(--pgv-radius-lg) var(--pgv-radius-lg) 0 0;
    }
    /* flex-basis runs along the main axis, so the 240px basis from
       .pgv-row > .pgv-field (set for the side-by-side desktop row) would
       otherwise become a min-*height* once the row stacks into a column,
       forcing each field open to ~240px tall. Reset it here. */
    .pgisfun-votes .pgv-row { flex-direction: column; gap: 0; }
    .pgisfun-votes .pgv-row > .pgv-field { flex-basis: auto; }
    .pgisfun-votes .pgv-bar-head { flex-direction: column; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
    .pgisfun-votes .pgv-bar-fill,
    .pgisfun-votes .pgv-card { transition: none; }
}

/* ---------- per-course date options ---------- */

.pgisfun-votes .pgv-card-dates {
    border: 0;
    border-top: 1px solid var(--pgv-border);
    margin: 0 0 14px;
    padding: 12px 0 0;
}
.pgisfun-votes .pgv-card-dates-legend {
    padding: 0;
    font-size: .82rem;
    font-weight: 600;
    color: var(--pgv-muted);
    margin: 0 0 8px;
}
.pgisfun-votes .pgv-chips-sm { gap: 6px; }
.pgisfun-votes .pgv-chips-sm .pgv-chip {
    padding: 6px 11px;
    font-size: .82rem;
    gap: 6px;
}
.pgisfun-votes .pgv-card-dates-hint {
    margin: 8px 0 0;
    font-size: .75rem;
    color: var(--pgv-muted);
}

/* Per-course date results, hanging off the course bar. */
.pgisfun-votes .pgv-bar-dates {
    list-style: none;
    margin: 8px 0 0;
    padding: 0 0 0 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: .8rem;
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-bar-dates b {
    font-weight: 600;
    color: inherit;
    margin-left: 4px;
}
.pgisfun-votes .pgv-bar-dates li.is-lead { color: var(--pgv-accent); }

/* ---------- per-course voting deadline ---------- */

.pgisfun-votes .pgv-card-closes,
.pgisfun-votes .pgv-card-closed {
    margin: 0 0 12px;
    font-size: var(--pgv-font-sm);
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-card-closed {
    font-weight: 600;
    color: var(--pgv-err);
}
.pgisfun-votes .pgv-card:has(.pgv-card-closed) { opacity: .72; }

/* ---------- share ---------- */

.pgisfun-votes .pgv-share {
    margin: 28px 0 0;
    padding: 20px 0 0;
    border-top: 1px solid var(--pgv-border);
}
.pgisfun-votes .pgv-share-label {
    margin: 0 0 12px;
    font-size: var(--pgv-font-sm);
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-share-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.pgisfun-votes .pgv-share-actions .pgv-btn {
    padding: .7rem 1.4rem;
    font-size: var(--pgv-font-sm);
}

/* ---------- remove-vote confirmation ---------- */

.pgisfun-votes .pgv-confirm {
    max-width: 34rem;
    padding: clamp(20px, 4vw, 32px);
    border: 1px solid var(--pgv-border);
    background: var(--pgv-bg-soft);
}
.pgisfun-votes .pgv-confirm-title { margin: 0 0 10px; }
.pgisfun-votes .pgv-confirm-text {
    margin: 0 0 22px;
    color: var(--pgv-muted);
}
.pgisfun-votes .pgv-confirm-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
