/* cv-dateinput.css — the shared typed/dropdown/calendar date field (cv-dateinput.js).

   Colours come from the host page through theme variables: the swipeslide player
   sets --ss-*, the dashboard sets --text-primary/--bg-panel/--accent. Every
   fallback is the DARK default, because that is what :root is when no theme
   attribute is present. */

.cvdi {
    --cvdi-text:     var(--ss-text, var(--text-primary, #f0f0f0));
    --cvdi-muted:    var(--ss-muted, var(--text-secondary, #888888));
    --cvdi-accent:   var(--ss-highlight, var(--accent, #6366f1));
    --cvdi-surface:  var(--ss-card, var(--bg-item, #1a1a1a));
    --cvdi-border:   var(--ss-border, var(--border, #333333));
    --cvdi-panel:    var(--ss-bg, var(--bg-panel, #101010));
    --cvdi-radius:   var(--ss-radius, 14px);
    display: block;
    width: 100%;
    margin-bottom: 14px;
    color: var(--cvdi-text);
}

/* ── The typed row: a real text box plus the button that opens the calendar ── */

.cvdi-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.cvdi-text {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 64px;
    padding: 16px 18px;
    border-radius: var(--cvdi-radius);
    background: var(--cvdi-surface);
    border: 2px solid var(--cvdi-border);
    color: var(--cvdi-text);
    /* 16px+ keeps iOS Safari from zooming the page when the field takes focus. */
    font-size: 1.15rem;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.cvdi-text::placeholder { color: var(--cvdi-muted); }

.cvdi-text:focus { border-color: var(--cvdi-accent); }

/* A finished date that does not parse — said quietly, the field keeps the text. */
.cvdi-text.cvdi-bad { border-color: var(--cr-warn, #e0a800); }

.cvdi-open {
    flex: 0 0 auto;
    width: 64px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--cvdi-radius);
    background: var(--cvdi-surface);
    border: 2px solid var(--cvdi-border);
    color: var(--cvdi-text);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.cvdi-open:hover,
.cvdi-open:focus-visible { border-color: var(--cvdi-accent); outline: none; }

/* ── The day / month / year dropdown row ── */

.cvdi-selects {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* The button that opens a list. A native <select> would hand the list to the
   operating system, which packs the rows tight — on a phone the days then sit
   so close that a thumb hits the wrong one. */
.cvdi-pick {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--cvdi-surface);
    border: 2px solid var(--cvdi-border);
    color: var(--cvdi-text);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.cvdi-pick:hover,
.cvdi-pick:focus-visible { border-color: var(--cvdi-accent); outline: none; }

.cvdi-pick-open { border-color: var(--cvdi-accent); }

.cvdi-pick-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cvdi-pick-empty .cvdi-pick-label { color: var(--cvdi-muted); }

.cvdi-pick-chev {
    flex: 0 0 auto;
    display: flex;
    opacity: 0.7;
}

/* The year sits widest — it is the one people hunt for. */
.cvdi-year { flex: 1.3 1 0; }

/* The list itself: one roomy row per value, so a thumb lands on the day it
   aimed at. Hangs off <body> so no slide can clip it. */
.cvdi-menu {
    position: fixed;
    overflow-y: auto;
    padding: 6px;
    border-radius: 14px;
    background: var(--cvdi-panel, var(--bg-panel, #101010));
    border: 1px solid var(--cvdi-border, var(--border, #333333));
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
    scrollbar-width: thin;
    scrollbar-color: var(--cvdi-thumb, rgba(255, 255, 255, 0.16)) transparent;
}

.cvdi-menu::-webkit-scrollbar { width: 10px; }
.cvdi-menu::-webkit-scrollbar-track { background: transparent; }
.cvdi-menu::-webkit-scrollbar-thumb {
    background: var(--cvdi-thumb, rgba(255, 255, 255, 0.16));
    background-clip: content-box;
    border: 2px solid transparent;
    border-radius: 8px;
}
.cvdi-menu::-webkit-scrollbar-thumb:hover {
    background: var(--cvdi-thumb-hover, rgba(255, 255, 255, 0.28));
    background-clip: content-box;
}

.cvdi-opt {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-bottom: 4px;
    padding: 12px 14px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--cvdi-text, var(--text-primary, #f0f0f0));
    font-size: 1.05rem;
    text-align: left;
    cursor: pointer;
}

.cvdi-opt:last-child { margin-bottom: 0; }

.cvdi-opt:hover { background: var(--cvdi-surface, var(--bg-item, #1a1a1a)); }

.cvdi-opt-sel {
    background: var(--cvdi-accent, var(--accent, #6366f1));
    color: var(--text-on-accent, #ffffff);
    font-weight: 700;
}

/* ── The big calendar ── */

.cvdi-pop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
}

.cvdi-card {
    --cvdi-text:     var(--ss-text, var(--text-primary, #f0f0f0));
    --cvdi-muted:    var(--ss-muted, var(--text-secondary, #888888));
    --cvdi-accent:   var(--ss-highlight, var(--accent, #6366f1));
    --cvdi-surface:  var(--ss-card, var(--bg-item, #1a1a1a));
    --cvdi-border:   var(--ss-border, var(--border, #333333));
    --cvdi-panel:    var(--ss-bg, var(--bg-panel, #101010));
    width: min(96vw, 440px);
    /* Short screens (a laptop, an embedded panel) get the whole calendar without
       it running off the bottom: the card caps at the screen and the day cells
       shrink with it — see .cvdi-cell. */
    max-height: min(86vh, 520px);
    overflow-y: auto;
    padding: 12px;
    border-radius: 18px;
    background: var(--cvdi-panel);
    border: 1px solid var(--cvdi-border);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    color: var(--cvdi-text);
    /* Styled like every other dark surface in the app — a browser-default bar
       reads blue and off-design. */
    scrollbar-width: thin;
    scrollbar-color: var(--cvdi-thumb, rgba(255, 255, 255, 0.16)) transparent;
}

.cvdi-card::-webkit-scrollbar { width: 10px; }
.cvdi-card::-webkit-scrollbar-track { background: transparent; }
.cvdi-card::-webkit-scrollbar-thumb {
    background: var(--cvdi-thumb, rgba(255, 255, 255, 0.16));
    background-clip: content-box;
    border: 2px solid transparent;
    border-radius: 8px;
}
.cvdi-card::-webkit-scrollbar-thumb:hover {
    background: var(--cvdi-thumb-hover, rgba(255, 255, 255, 0.28));
    background-clip: content-box;
}

.cvdi-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.cvdi-headsel {
    flex: 1 1 auto;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.cvdi-nav,
.cvdi-x {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--cvdi-surface);
    border: 1px solid var(--cvdi-border);
    color: var(--cvdi-text);
    cursor: pointer;
}

.cvdi-nav:hover,
.cvdi-x:hover { border-color: var(--cvdi-accent); }

.cvdi-wd,
.cvdi-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cvdi-wd {
    margin-bottom: 3px;
    color: var(--cvdi-muted);
    font-size: 0.74rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cvdi-cell {
    /* Six rows have to fit the screen that is there: the cell follows the
       viewport height and stops at a thumb-sized 48px on a tall one. */
    height: clamp(34px, 6.4vh, 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--cvdi-surface);
    border: 1px solid transparent;
    color: var(--cvdi-text);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.cvdi-cell-empty { background: transparent; cursor: default; }

.cvdi-cell:hover:not(:disabled) { border-color: var(--cvdi-accent); }

/* Today, lightly. It was drawn with the SAME border colour as every other cell, so
   "now" was invisible in the grid and picking a deadline meant counting rows. An accent
   ring, accent numerals and a faint tint — never a solid fill, because a filled cell
   means SELECTED and nothing else. (user 2026-08-20) */
.cvdi-cell-today {
    border-color: var(--cvdi-accent);
    color: var(--cvdi-accent);
    font-weight: 700;
    /* Dropped whole by a browser without color-mix; the ring and the numerals still mark
       the day there, so the fallback is the same cell minus the tint. */
    background: color-mix(in srgb, var(--cvdi-accent) 12%, var(--cvdi-surface));
}

.cvdi-cell-sel {
    background: var(--cvdi-accent);
    color: var(--text-on-accent, #ffffff);
    font-weight: 700;
}

/* The day that was chosen beats the day that is today: today keeps only its ring. */
.cvdi-cell-sel.cvdi-cell-today {
    background: var(--cvdi-accent);
    color: var(--text-on-accent, #ffffff);
}

.cvdi-cell-off { opacity: 0.3; cursor: not-allowed; }

.cvdi-foot {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.cvdi-foot-btn {
    flex: 1 1 0;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    background: var(--cvdi-surface);
    border: 1px solid var(--cvdi-border);
    color: var(--cvdi-text);
    font-size: 0.95rem;
    cursor: pointer;
}

.cvdi-foot-btn:hover { border-color: var(--cvdi-accent); }

.cvdi-done {
    background: var(--cvdi-accent);
    border-color: var(--cvdi-accent);
    color: var(--text-on-accent, #ffffff);
    font-weight: 600;
}

/* The month and year buttons in the calendar header sit in a 40px row. */
.cvdi-headsel .cvdi-pick {
    min-height: 40px;
    padding: 6px 10px;
    border-width: 1px;
    border-radius: 10px;
    font-size: 0.95rem;
}

/* A phone gets the same calendar, just tighter — the cells and the list rows
   stay thumb-sized, because that is the whole reason for our own list. */
@media (max-width: 520px) {
    .cvdi-card { padding: 10px; border-radius: 16px; }
    .cvdi-cell { height: clamp(34px, 5.4vh, 46px); font-size: 1rem; }
    .cvdi-selects { gap: 6px; }
    .cvdi-pick { min-height: 54px; font-size: 1.02rem; }
    .cvdi-opt { min-height: 54px; padding: 14px 16px; margin-bottom: 6px; }
    .cvdi-menu { padding: 8px; }
}
