/* =========================================================
   CONFIG (edit these in ONE place)
   ========================================================= */
:root {
    /* Primary colors */
    --c-gray: #2c2c2c;
    --c-red: #ec1a2e;
    --c-white: #ffffff;

    /* Messages must be black (per your requirement) */
    --c-message: #000000;

    /* Fonts (change these 3 to switch the whole site) */
    --font-title: Helvetica, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    --font-text: Helvetica, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    --font-counter: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;

    /* Button + message font (defaults to text font, but configurable) */
    --font-button: var(--font-text);
    --font-message: var(--font-text);

    /* Layout */
    --container-max: 980px;
    --container-pad: 1.25rem;

    /* Intro text size (rem, as requested) */
    --intro-size: 1.35rem;

    /* Animations (configurable) */
    --msg-roll-duration: 420ms; /* message rollout speed */
    --digit-roll-duration: 520ms; /* counter digit roll speed */

    /* Spacing */
    --radius: 14px;
    --gap: 0.4rem;
    --msg-gap: 0.75rem; /* space between button and message */
}

/* =========================================================
   Base / reset
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--c-white);
    color: var(--c-gray);
    font-family: var(--font-text);
    display: flex;
    flex-direction: column;

    /* safe-area for iOS */
    padding-bottom: env(safe-area-inset-bottom);
}

header {
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-pad);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    clip: rect(0, 0, 0, 0);
    overflow: hidden;
    white-space: nowrap;
}

/* =========================================================
   Header (gray) with logo left and counter right
   ========================================================= */
.site-header {
    background: var(--c-gray);
    color: var(--c-white);
    position: relative;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    display: block;
    height: 115%;
    width: auto;
    position: absolute;
    bottom: -24%
}

/* Counter */
.counter-block {
    text-align: right;
    min-width: 10rem;
}

.counter-label {
    font-family: var(--font-text);
    font-size: 0.95rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

/* big number on the right */
.counter-number {
    font-family: var(--font-counter);
    font-variant-numeric: tabular-nums;
    font-size: clamp(1.6rem, 3.4vw, 2.8rem);
    line-height: 1.05;
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 0;
    color: var(--c-red);
    min-height: clamp(1.6rem, 3.4vw, 2.8rem);
}

/* Digit wheel (odometer style) */
.digit-wheel {
    display: inline-block;
    overflow: hidden;
    height: 1em; /* exactly one digit line */
    width: 0.7em;
    position: relative;
}

.digit-stack {
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition-property: transform;
    transition-duration: var(--digit-roll-duration);
    transition-timing-function: cubic-bezier(0.2, 0.9, 0.25, 1);
    will-change: transform;
}

.digit-item {
    height: 1em;
    line-height: 1em;
    text-align: center;
}

/* separators like commas (static) */
.counter-sep {
    display: inline-block;
    padding: 0 0.08em;
    color: var(--c-red);
}

/* =========================================================
   Main
   ========================================================= */
.site-main {
    flex: 1;
}

.main-inner {
    padding: 1.5rem 0 2rem;
    display: grid;
    gap: 1.25rem;
}

.intro-text {
    margin: 0;
    font-family: var(--font-title);
    font-size: var(--intro-size);
    line-height: 1.25;
}

/* Form */
.vote-form {
    width: 100%;
    max-width: 46rem;
    display: grid;
    gap: var(--gap);
}

/* Comment field wrapper */
.comment-wrap {
    position: relative;
}

.comment-input {
    width: 100%;
    min-height: 3.2rem;
    resize: vertical;
    padding: 0.9rem 0.95rem 1.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--c-gray);
    outline: none;
    font-family: var(--font-text);
    font-size: 1rem;
    line-height: 1.3;
    color: var(--c-gray);
}

.comment-input::placeholder {
    opacity: 0.6;
}


.comment-counter {
    position: absolute;
    right: 0.85rem;
    bottom: 0.55rem;
    font-size: 0.9rem;
    opacity: 0.75;
}

/* Submit row */
.submit-row {
    display: flex;
    align-items: center;
    gap: var(--msg-gap);
    min-width: 0; /* allow message to truncate */
    margin-bottom: 0.3rem;
}

/* Button */
.vote-button {
    appearance: none;
    border: none;
    border-radius: var(--radius);
    background: var(--c-red);
    color: var(--c-white);
    font-family: var(--font-button);
    font-size: 1rem;
    font-weight: 650;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    white-space: nowrap;
}

.vote-button:active {
    transform: translateY(1px);
}

.vote-button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Message (rolls out to the right of the button) */
.vote-message {
    font-family: var(--font-message);
    color: var(--c-message);
    font-size: 1rem;

    /* ensure one-line, and never wraps */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    /* rollout effect */
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    transition: clip-path var(--msg-roll-duration) ease-out,
    opacity var(--msg-roll-duration) ease-out;

    /* occupy remaining space */
    flex: 1;
    min-width: 0;
}

.vote-message.is-visible {
    opacity: 1;
    clip-path: inset(0 0 0 0);
}

/* Blink effect (for repeated errors without duplicating message) */
@keyframes msgBlink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
    }
}

.vote-message.blink {
    animation: msgBlink 250ms ease-in-out 2;
}

/* Turnstile */
.turnstile-row {
    display: flex;
    justify-content: flex-start;
}

/* =========================================================
   Footer (sticky to bottom, no gray background)
   ========================================================= */
.site-footer {
    padding: 0.9rem 0 calc(0.9rem + env(safe-area-inset-bottom));
}

.footer-text {
    font-family: var(--font-text);
    font-size: 0.85rem;
    opacity: 0.75;
}


@media (max-width: 1050px) {
    .site-main, .site-footer {
        margin-left: 2rem;
        margin-right: 2rem;
    }

    header {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (max-width: 500px) {
    .site-main, .site-footer {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    header {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

.site-footer > .container {
    padding-left: 0;
    padding-right: 0;
}

/* Accessibility: reduce motion */
@media (prefers-reduced-motion: reduce) {
    .digit-stack,
    .vote-message {
        transition: none !important;
    }
    .vote-message.blink {
        animation: none !important;
    }
}
