/* Countdown tiles -- big friendly counts to a date. LeonardoWeb port of the
   Leonardo Hearth Countdowns page. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #F2F2F4; color: #222;
    font-family: "Segoe UI", system-ui, sans-serif; }

/* Full-height shell: only .cd-body scrolls, so the injected icon band and the
   black header stay pinned at the top (never scroll off). */
.page-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#lwIconBand, .ct-header { flex: 0 0 auto; }

.ct-header {
    background: #3C3C3C; color: #fff; padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
}
.ct-header h1 { margin: 0; font-size: 14pt; font-weight: 600; flex: 1; }
.ct-header button {
    color: #fff; background: #4F46E5; border: none; border-radius: 4px;
    padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.ct-header button:hover { background: #6257F0; }

.cd-body { flex: 1; overflow: auto; padding: 16px; }
.cd-hint { font-size: 12px; color: #777; margin-bottom: 12px; min-height: 14px; }

.cd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

.cd-tile {
    position: relative; border-radius: 16px; padding: 20px 16px 16px;
    color: #fff; cursor: pointer; overflow: hidden;
    min-height: 150px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
    border: 1px solid rgba(255,255,255,.14); box-shadow: 0 6px 18px rgba(0,0,0,.15);
}
.cd-tile:hover { filter: brightness(1.06); }
.cd-tile .cd-emoji { font-size: 30px; line-height: 1; margin-bottom: 6px; }
.cd-tile .cd-num { font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.cd-tile .cd-unit { font-size: 14px; font-weight: 600; opacity: .92; margin-top: 2px; }
.cd-tile .cd-title { font-size: 16px; font-weight: 700; margin-top: 10px; word-break: break-word; }
.cd-tile .cd-date { font-size: 12px; opacity: .85; margin-top: 3px; }
.cd-tile.past { opacity: .82; }
.cd-tile.today .cd-num { font-size: 30px; }

/* Palette -- friendly gradients keyed by ColorKey. */
.cd-blue   { background: linear-gradient(135deg, #2563eb, #1e40af); }
.cd-green  { background: linear-gradient(135deg, #1f9d55, #12683a); }
.cd-pink   { background: linear-gradient(135deg, #e0559b, #b03072); }
.cd-orange { background: linear-gradient(135deg, #e8843b, #c05f16); }
.cd-purple { background: linear-gradient(135deg, #8b5cf6, #6532c9); }
.cd-red    { background: linear-gradient(135deg, #d9534f, #a5312d); }
.cd-teal   { background: linear-gradient(135deg, #0ea5b7, #0b7683); }

.cd-empty {
    background: #fff; border: 1px dashed #CFCFD6; border-radius: 12px;
    padding: 30px 20px; color: #777; text-align: center; grid-column: 1 / -1;
}
.cd-loading { color: #999; text-align: center; padding: 30px; grid-column: 1 / -1; }

/* ---- Add / edit modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none;
    align-items: center; justify-content: center; z-index: 50; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 8px; width: min(460px, 94vw); max-height: 90vh;
    overflow: auto; padding: 18px 20px; }
.modal h2 { margin: 0 0 14px; font-size: 16px; color: #333; }

.cd-field { display: block; margin: 0 0 12px; }
.cd-field > span { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.cd-field input {
    display: block; width: 100%; box-sizing: border-box; padding: 8px 10px;
    font-size: 14px; color: #1a1a1a; background: #fff;
    border: 1px solid #ccc; border-radius: 4px; font-family: inherit;
}
.cd-field input:focus { outline: none; border-color: #4F46E5; }
/* Defend the full-width input against the picasso-voice inline wrap. */
.cd-field .voice-mic-wrap { display: block; }

.cd-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.cd-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    border: 3px solid transparent; }
.cd-swatch.on { border-color: #1a1a1a; }

.cd-modal-btns { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.cd-modal-btns .spacer { flex: 1 1 auto; }
.cd-modal-btns button { border: none; border-radius: 4px; padding: 9px 16px;
    font: inherit; font-size: 13px; cursor: pointer; }
.cd-btn-save { background: #4F46E5; color: #fff; }
.cd-btn-save:hover { background: #6257F0; }
.cd-btn-cancel { background: #E9E9EF; color: #333; }
.cd-btn-cancel:hover { background: #DDD; }
.cd-btn-delete { background: none; color: #C0392B; border: 1px solid rgba(192,57,43,.4) !important; }
.cd-btn-delete:hover { background: rgba(192,57,43,.08); }

/* Leonardo Find deep-link flash (Story 2358) -- ?focus=<CountdownID> lands
   here and lights the tile so the eye finds it on a crowded board. */
.cd-tile.cd-find-flash {
    animation: cd-find-flash 1.6s ease-out 1;
}

@keyframes cd-find-flash {
    0%   { box-shadow: 0 0 0 4px #F4C430; }
    70%  { box-shadow: 0 0 0 4px rgba(244, 196, 48, 0.35); }
    100% { box-shadow: none; }
}
