/* ============================================================
   Month calendar for the builder's date fields
   Same look as the rest of the site: navy for the choice, green for
   today and focus, cool grays, 8-12px corners, quiet shadows.
   ============================================================ */

/* The calendar opens inside the entry card */
.experience-entry:has(#calendarPopupOverlay),
.education-entry:has(#calendarPopupOverlay),
.cert-entry:has(#calendarPopupOverlay) {
    overflow: visible !important;
}
.experience-item, .experience-entry,
.education-item,  .education-entry,
.certificate-item,.cert-entry,
.language-item { position: relative !important; }

@keyframes calFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes calPopIn  {
    from { opacity: 0; transform: translateY(6px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* ── Scrim over the card ── */
.calendar-popup-overlay {
    position: absolute;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
    border-radius: inherit;
    background: rgba(15, 28, 53, .28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: calFadeIn .15s ease forwards;
}

/* ── Popup ── */
.calendar-popup {
    position: relative;
    max-width: 100%;
    box-sizing: border-box;
    padding: 16px;
    background: #fff;
    border: 1px solid #E4E7EC;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 12px 24px -8px rgba(16,24,40,.18), 0 32px 64px -24px rgba(16,24,40,.32);
    font-family: inherit;
    animation: calPopIn .18s cubic-bezier(.2,0,0,1) forwards;
}

.cal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.cal-label {
    font-size: 12px; line-height: 16px; font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase;
    color: #667085;
}
.cal-value {
    margin-top: 2px;
    font-size: 20px; line-height: 28px; font-weight: 600;
    letter-spacing: -.01em;
    color: #0F1C35;
    font-variant-numeric: tabular-nums;
    transition: color .15s ease;
}
.cal-value.is-preview { color: #475467; }
.cal-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; margin: -4px -6px 0 0; padding: 0;
    border: 0; border-radius: 8px;
    background: none; color: #98A2B3;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.cal-close:hover { background: #F2F4F7; color: #0F1C35; }

/* ── Year bar ── */
.cal-yearbar {
    display: grid;
    grid-template-columns: 36px 1fr 36px;
    gap: 6px;
    margin-bottom: 12px;
}
.year-nav-btn,
.custom-year-display {
    display: inline-flex; align-items: center; justify-content: center;
    height: 36px; padding: 0;
    border: 1px solid #D0D5DD; border-radius: 8px;
    background: #fff; color: #344054;
    font: inherit;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.year-nav-btn:hover,
.custom-year-display:hover { background: #F8F9FB; border-color: #98A2B3; color: #0F1C35; }
.custom-year-display { gap: 6px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.custom-year-display svg { width: 14px; height: 14px; color: #98A2B3; transition: transform .15s ease; }
.custom-year-display.active { border-color: #0F1C35; }
.custom-year-display.active svg { transform: rotate(180deg); }

/* Year list (on <body>, positioned by the script) */
.custom-year-dropdown {
    position: fixed;
    z-index: 999999;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    background: #fff;
    border: 1px solid #E4E7EC;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 12px 24px -8px rgba(16,24,40,.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
    scrollbar-width: thin;
    scrollbar-color: #D0D5DD transparent;
}
.custom-year-dropdown.open { opacity: 1; visibility: visible; transform: none; }
.year-option {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px; font-weight: 500; color: #344054;
    font-variant-numeric: tabular-nums;
    text-align: center;
    cursor: pointer;
}
.year-option:hover { background: #F2F4F7; color: #0F1C35; }
.year-option.selected { background: #0F1C35; color: #fff; font-weight: 600; }

/* ── Months: 4 x 3, big targets ── */
.clean-month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.month-btn {
    position: relative;
    height: 40px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #F8F9FB;
    color: #344054;
    font: inherit; font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.month-btn:hover { background: #ECF6F1; border-color: #CDE8DA; color: #05603A; }
.month-btn:focus-visible { outline: none; border-color: #0B7A53; box-shadow: 0 0 0 3px rgba(11,122,83,.18); }
/* today: a small green dot */
.month-btn.is-today::after {
    content: "";
    position: absolute; left: 50%; bottom: 5px;
    width: 4px; height: 4px; margin-left: -2px;
    border-radius: 50%;
    background: #0B7A53;
}
.month-btn.selected,
.month-btn.selected:hover { background: #0F1C35; border-color: #0F1C35; color: #fff; font-weight: 600; }
.month-btn.selected.is-today::after { background: #7BD4AC; }

/* ── Footer ── */
.cal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #F2F4F7;
}
.cal-clear,
.cal-today {
    height: 32px; padding: 0 10px;
    border: 0; border-radius: 6px;
    background: none;
    font: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}
.cal-clear { color: #B42318; margin-left: -10px; }
.cal-clear:hover { background: #FEF3F2; }
.cal-today { color: #05603A; margin-right: -10px; }
.cal-today:hover { background: #ECF6F1; }

@media (prefers-reduced-motion: reduce) {
    .calendar-popup, .calendar-popup-overlay { animation: none; }
}

/* ── The date field ── */
.date-input {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 11px 44px 11px 14px;
    font-size: 14px; font-weight: 500; color: #1e293b;
    cursor: pointer; width: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398A2B3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
}
.date-input::placeholder { color: #94a3b8; }
.date-input:hover  { border-color: #98A2B3; }
.date-input:focus  { outline: none; border-color: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.date-input.disabled { background: #f1f5f9; cursor: not-allowed; opacity: .55; color: #94a3b8; }

.form-section { position: relative; }
body.calendar-open { overflow: hidden; }

/* ── Clearing a date ── */
/* The field can't be typed in (the calendar opens instead), so it gets its own clear button */
.date-input { padding-right: 34px !important; }
.date-clear {
    position: absolute; right: 8px; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; padding: 0;
    border: 0; border-radius: 50%;
    background: #F2F4F7; color: #667085;
    cursor: pointer; z-index: 2;
    transition: background .15s ease, color .15s ease;
}
.date-clear[hidden] { display: none; }
.date-clear:hover { background: #E4E7EC; color: #101828; }
.date-clear:focus-visible { outline: 2px solid #10b981; outline-offset: 1px; }
