@layer components {
/* Date-picker — readonly trigger + popover containing the calendar grid.
   Reuses .psw-field chrome; adds the trigger cursor, right-edge calendar
   icon, the open-state ring, and the popover surface + month-nav header. */

.psw-date-picker { position: relative; }

.psw-date-picker__trigger {
    cursor: pointer;
    padding-right: 44px;
}
.psw-date-picker__trigger:disabled { cursor: not-allowed; }

.psw-date-picker__icon {
    right: 16px;
    color: var(--color-gray-700);
}
.psw-field--disabled .psw-date-picker__icon { color: var(--color-content-disabled); }

.psw-date-picker--open .psw-date-picker__trigger {
    border-color: transparent;
    box-shadow: 0 0 0 3px var(--theme-primary, var(--theme-primary-default));
}
.psw-date-picker--open.psw-field--error .psw-date-picker__trigger {
    box-shadow: 0 0 0 3px var(--color-danger-400);
}

.psw-date-picker__popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    /* Fixed 320px card (Figma 2347:21035), independent of the trigger it hangs
       under: the calendar grid is a fixed 7 × 40px, so stretching the popover to
       a wide trigger (the 638px desktop form column) only padded it with empty
       space. 320px also clears the grid's intrinsic 314px (280px grid + 32px
       padding + 2px border), so no column clips. */
    width: 320px;
    z-index: 10;
    background: var(--color-white);
    border: var(--border-width-sm, 1px) solid var(--color-border-default);
    border-radius: var(--radius-lg);
    /* Drop-shadow from Figma frame 2347:21035 (5% black, 20px blur). */
    box-shadow: 0 5px 20px 0 rgba(0, 0, 0, 0.05);
    padding: var(--space-4);
    box-sizing: border-box;
}
.psw-date-picker__popover[hidden] { display: none; }

/* Fit the calendar grid inside the 288px popover interior (320px − 32px
   popover padding). The calendar primitive carries its own 8px padding +
   `overflow: hidden`, so without zeroing it the 7×40px grid would clip
   the rightmost column. */
.psw-date-picker__popover .psw-calendar {
    padding: 0;
    --psw-calendar-cell-width: 40px;
    --psw-calendar-cell-height: 40px;
    --psw-calendar-selected-size: 36px;
}

/* Show outside-month days faded rather than hidden (the standalone calendar
   primitive hides them). Scoped so the standalone calendar gallery is
   unaffected. Day-number color (black), the selected circle (primary /
   cobalt), and the hover tint (secondary) all inherit from the calendar
   primitive per the designer review — the earlier blue/navy popover palette
   (Figma frame 2347:21035) was reversed. */
.psw-date-picker__popover .psw-date-cell--outside {
    visibility: visible;
    color: var(--color-content-disabled);
}

.psw-date-picker__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
/* The month/year title is the drill-down toggle (day -> month -> year), so it's
   a button — reset the chrome, lay the label + chevron in a row, and add a
   hover/focus affordance. */
.psw-date-picker__nav-month {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: var(--font-weight-bold);
    font-size: var(--text-label-md);
    line-height: var(--text-label-md--line-height);
    color: var(--color-content-high);
    transition: background-color 120ms ease;
}
.psw-date-picker__nav-month:hover { background: var(--color-gray-100); }
.psw-date-picker__nav-month:focus-visible {
    outline: 2px solid var(--theme-primary, var(--theme-primary-default));
    outline-offset: 2px;
}
/* Chevron hints the title drills down; hidden by JS in year view (the top
   level). It sets its own display, so re-hide on [hidden] (UA rule alone loses
   to the inline-flex above). */
.psw-date-picker__nav-month-chevron {
    display: inline-flex;
    color: var(--color-content-medium);
}
.psw-date-picker__nav-month-chevron[hidden] { display: none; }

/* Month- and year-selection grids — reuse .psw-date-cell for type/hover/
   selected, laid out 3-up so 4-digit years (and abbreviated month names) fit.
   One is shown at a time as the nav-month title drills down. */
.psw-date-picker__months,
.psw-date-picker__years {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
    /* A day cell's hover/active/selected fill is a fixed 36px circle — too
       narrow for a month name or 4-digit year. Override the shared fill hook
       (psw-calendar.css, circle as fallback) so every state fills the whole
       cell as a pill, including the primary selected fill. */
    --psw-date-cell-fill-width: 100%;
    --psw-date-cell-fill-height: 100%;
}
.psw-date-picker__months[hidden],
.psw-date-picker__years[hidden] { display: none; }
/* While a drill grid is shown the day grid is `hidden`, but .psw-calendar sets
   its own `display: flex`, which beats the UA `[hidden]` rule — re-hide it here
   (scoped to the popover so the standalone calendar is unaffected). */
.psw-date-picker__popover .psw-calendar[hidden] { display: none; }
.psw-date-picker__nav-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--color-content-medium);
    border-radius: var(--radius-max);
    cursor: pointer;
    padding: 0;
    transition: background-color 120ms ease;
}
.psw-date-picker__nav-btn .psw-icon { color: currentColor; }
.psw-date-picker__nav-btn:hover { background: var(--color-gray-100); }
.psw-date-picker__nav-btn:focus-visible {
    outline: 2px solid var(--theme-primary, var(--theme-primary-default));
    outline-offset: 2px;
}
.psw-date-picker__nav-btn:disabled {
    color: var(--color-content-disabled);
    cursor: not-allowed;
    background: transparent;
}
}
