/* ==========================================================================
   TGF submission-cutoff bar
   ==========================================================================
   Replaces wordpress-countdown-banner's bottom bar, and since 1.27.1 copies its
   "digital countdown" look exactly as it ran on gradeit.co.za: a black bar, one
   card per timer in that timer's own colours with a 24px logo, a bold title over
   a one-line note, and green-on-black DAYS : HRS : MIN : SEC blocks. Values were
   read off the live old banner (including its global overrides: black
   background, 12px 20px padding, 12px labels), not guessed.

   Per-timer colours arrive as custom properties on the card:
     --tgf-cb-bg  card background   (default #222)
     --tgf-cb-fg  title, note, unit labels (default #fff)
   The digits are deliberately not themeable: green on black is the look.
   ========================================================================== */

.tgf-cutoff-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 12px 20px;
    background: #000;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border-top: 1px solid #444;
    overflow: hidden;
    font-family: Montserrat, sans-serif;
    font-size: 14px;
    line-height: 1.3;
    z-index: 999;
    animation: tgf-cutoff-slide-up 0.5s ease-in-out;
    box-sizing: border-box;
}

.tgf-cutoff-bar *,
.tgf-cutoff-bar *::before,
.tgf-cutoff-bar *::after {
    box-sizing: border-box;
}

@keyframes tgf-cutoff-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* The old banner's slow shine across the bar. */
.tgf-cutoff-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: tgf-cutoff-shine 3s infinite;
    pointer-events: none;
}

@keyframes tgf-cutoff-shine {
    to { left: 100%; }
}

.tgf-cutoff-bar__inner {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
}

.tgf-cutoff-bar__scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}
.tgf-cutoff-bar__scroll::-webkit-scrollbar { height: 4px; }
.tgf-cutoff-bar__scroll::-webkit-scrollbar-track { background: transparent; }
.tgf-cutoff-bar__scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 2px; }
.tgf-cutoff-bar__scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }

.tgf-cutoff-bar__track {
    display: flex;
    gap: 15px;
    padding: 4px 0;
    min-width: max-content;
}

/* Only scrolls when the cards genuinely overflow — the JS adds this class and
   clones the track once, so a short list sits still instead of sliding. */
.tgf-cutoff-bar__track.is-scrolling {
    animation: tgf-cutoff-marquee 20s linear infinite;
}
.tgf-cutoff-bar__track.is-scrolling:hover { animation-play-state: paused; }

@keyframes tgf-cutoff-marquee {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* --- One timer --------------------------------------------------------- */

.tgf-cutoff-bar__block {
    --tgf-cb-bg: #222;
    --tgf-cb-fg: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 6px;
    background: var(--tgf-cb-bg);
    color: var(--tgf-cb-fg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.tgf-cutoff-bar__block:hover,
.tgf-cutoff-bar__block:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    border-color: #555;
    color: var(--tgf-cb-fg);
    text-decoration: none;
}

.tgf-cutoff-bar__block:focus-visible {
    outline: 2px solid #f5cb45;
    outline-offset: 2px;
}

/* Inside the timer's urgent window: a red edge, nothing louder. */
.tgf-cutoff-bar__block.is-urgent {
    border-color: #ec3b33;
    box-shadow: 0 0 0 1px #ec3b33, 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tgf-cutoff-bar__head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
}

.tgf-cutoff-bar__logo {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 3px;
}

.tgf-cutoff-bar__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
}

.tgf-cutoff-bar__title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

.tgf-cutoff-bar__note {
    font-size: 10px;
    line-height: 1.2;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* --- The digital clock ------------------------------------------------- */

.tgf-cutoff-bar__clock {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', monospace;
    font-weight: 600;
}

.tgf-cutoff-bar__unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 28px;
}

.tgf-cutoff-bar__num {
    min-width: 24px;
    padding: 2px 4px;
    border: 1px solid #333;
    border-radius: 2px;
    background: #111;
    color: #00ff88;
    text-shadow: 0 0 2px rgba(0, 255, 136, 0.3);
    font-size: 14px;
    line-height: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.tgf-cutoff-bar__label {
    color: var(--tgf-cb-fg);
    font-family: Montserrat, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    line-height: 1;
    text-transform: uppercase;
}

.tgf-cutoff-bar__sep {
    margin: 0 1px;
    color: #666;
    font-size: 12px;
    font-weight: bold;
    animation: tgf-cutoff-blink 2s infinite;
}

@keyframes tgf-cutoff-blink {
    0%, 50%   { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* --- The standing notice ----------------------------------------------- */

.tgf-cutoff-bar__warning {
    margin: 6px 0 0;
    font-size: 11px;
    line-height: 1.35;
    color: #fff;
    opacity: 0.75;
    text-align: center;
}

/* --- Room for the bar at the end of the page ---------------------------
   The bar is fixed over the bottom of the window, so without this the last
   ~110px of every page (the footer) sits behind it. The page reserves the
   bar's height after its content, so the footer ends just above the bar.
   The custom property is the bar's measured height (cutoff-bar.js); the
   fallbacks are its usual heights, so the footer is clear even before
   wp-rocket lets the script run. */
body:has(.tgf-cutoff-bar) {
    padding-bottom: var(--tgf-cutoff-bar-h, 116px);
}
@media (max-width: 768px) {
    body:has(.tgf-cutoff-bar) {
        padding-bottom: var(--tgf-cutoff-bar-h, 92px);
    }
}

/* --- Smaller screens: the old banner's own breakpoints ------------------ */

@media (max-width: 768px) {
    .tgf-cutoff-bar { padding: 10px 15px; font-size: 13px; }
    .tgf-cutoff-bar__block { padding: 6px 10px; gap: 10px; }
    .tgf-cutoff-bar__head { gap: 6px; }
    .tgf-cutoff-bar__logo { width: 20px; height: 20px; }
    .tgf-cutoff-bar__info { min-width: 60px; }
    .tgf-cutoff-bar__title { font-size: 11px; }
    .tgf-cutoff-bar__note { font-size: 9px; max-width: 100px; }
    .tgf-cutoff-bar__num { font-size: 12px; min-width: 20px; padding: 1px 2px; }
    .tgf-cutoff-bar__label { font-size: 9px; }
    .tgf-cutoff-bar__sep { font-size: 10px; }
    .tgf-cutoff-bar__warning { font-size: 10px; margin-top: 4px; }
}

@media (max-width: 480px) {
    .tgf-cutoff-bar { padding: 8px 12px; font-size: 12px; }
    .tgf-cutoff-bar__track { gap: 12px; }
    .tgf-cutoff-bar__block { padding: 5px 8px; gap: 8px; }
    .tgf-cutoff-bar__head { gap: 5px; }
    .tgf-cutoff-bar__logo { width: 18px; height: 18px; }
    .tgf-cutoff-bar__info { min-width: 50px; }
    .tgf-cutoff-bar__title { font-size: 10px; }
    .tgf-cutoff-bar__note { font-size: 8px; max-width: 80px; }
    .tgf-cutoff-bar__num { font-size: 11px; min-width: 18px; padding: 1px; }
    .tgf-cutoff-bar__unit { min-width: 22px; }
    .tgf-cutoff-bar__label { font-size: 7px; }
    .tgf-cutoff-bar__sep { font-size: 9px; }
    .tgf-cutoff-bar__warning { font-size: 9px; }
}

/* An always-moving bar at the bottom of every page is exactly what this setting
   is for: the cards and clocks stay, the motion goes. */
@media (prefers-reduced-motion: reduce) {
    .tgf-cutoff-bar,
    .tgf-cutoff-bar::before,
    .tgf-cutoff-bar__track.is-scrolling,
    .tgf-cutoff-bar__sep {
        animation: none;
    }
}

/* --- Inline timers in page content ({cutoff_timers}, How it works) ------- */

/* An even grid of equal cards, not the bar's free-flowing row: each card is
   logo + title on the left and a fixed-width clock on the right, so every
   clock lines up down the column. */
.tgf-cutoff-inline {
    container-type: inline-size;
    margin: 14px 0 4px;
    font-family: Montserrat, sans-serif;
    font-size: 14px;
    line-height: 1.3;
}
.tgf-cutoff-inline *,
.tgf-cutoff-inline *::before,
.tgf-cutoff-inline *::after {
    box-sizing: border-box;
}
/* A flex/grid child will not shrink below its widest content unless told to;
   without this the timers push the page sideways on a phone. */
.tgf-step__body:has(.tgf-cutoff-inline),
.tgf-cutoff-inline,
.tgf-cutoff-inline__list {
    min-width: 0;
    max-width: 100%;
}
.tgf-cutoff-inline__list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}
/* In two columns, an odd one out spans the row rather than leaving a hole. */
@container (min-width: 1000px) {
    .tgf-cutoff-inline__list > .tgf-cutoff-bar__block:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}
.tgf-cutoff-inline .tgf-cutoff-bar__block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    min-height: 58px;
    padding: 9px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    white-space: normal;
}
.tgf-cutoff-inline .tgf-cutoff-bar__block:hover,
.tgf-cutoff-inline .tgf-cutoff-bar__block:focus-visible {
    transform: translateY(-1px);
}
.tgf-cutoff-inline .tgf-cutoff-bar__head {
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    gap: 10px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__logo {
    width: 28px;
    height: 28px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__info {
    min-width: 0;
    gap: 3px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__title {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tgf-cutoff-inline .tgf-cutoff-bar__note {
    max-width: none;
    font-size: 11px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__clock {
    flex: 0 0 auto;
    align-items: flex-start;
    gap: 3px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__unit {
    min-width: 30px;
    gap: 3px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__num {
    min-width: 28px;
    padding: 3px 4px;
    font-size: 15px;
}
.tgf-cutoff-inline .tgf-cutoff-bar__label {
    font-size: 9px;
    letter-spacing: 0.6px;
    opacity: 0.85;
}
/* Colons sit level with the digits, not halfway down to the labels. */
.tgf-cutoff-inline .tgf-cutoff-bar__sep {
    margin: 0;
    line-height: 23px;
}
.tgf-cutoff-inline__warning {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    opacity: 0.8;
}

/* One card per row, so every title is whole and every clock sits on the same
   right edge. Two columns only where there is room for both without
   truncating a title — measured on the step itself, not the window. */
@container (min-width: 1000px) {
    .tgf-cutoff-inline__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Phones: the clock drops under the title, still right-aligned. */
@container (max-width: 400px) {
    .tgf-cutoff-inline .tgf-cutoff-bar__block {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .tgf-cutoff-inline .tgf-cutoff-bar__head { flex: 1 1 100%; }
    .tgf-cutoff-inline .tgf-cutoff-bar__clock { margin-left: auto; }
    /* Narrow enough that a long name would be cut: let it take two lines. */
    .tgf-cutoff-inline .tgf-cutoff-bar__title { white-space: normal; }
}
