/* ==========================================================================
   CALENDAR WIDGET – FULL CSS (Phase 1)
   Location: widgets/calendar/calendar.css
   ========================================================================== */


/* ----------------------------------------------
   ROOT: Calendar Widget Body
   ---------------------------------------------- */

/* Base visual tokens only (no layout yet) */
.widget-calendar {
    width: 100%;
    height: 100%;
    padding: var(--widget-padding);
    gap: var(--space-md);
    font-family: inherit;
}

/* Default layout for non-grid archetypes:
   calendar body is a flex column
*/
.widget:not(.widget--archetype-grid) .widget-calendar {
    display: flex;
    flex-direction: column;
}

/* Layout for GRID archetype:
   the calendar itself becomes a 4-row grid:
   1) header
   2) weekday labels
   3) month grid (fills remaining space)
   4) meta line
*/
.widget.widget--archetype-grid .widget-calendar {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
}


/* ----------------------------------------------
   HEADER ROW (Prev | Month-Label | Next)
   ---------------------------------------------- */

.calendar-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: calc(1rem * var(--widget-font-scale));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-primary);
    padding-bottom: var(--space-sm);
    user-select: none;
}

.calendar-nav {
    background: none;
    border: none;
    padding: var(--space-xs) var(--space-sm);
    font-size: calc(1.25rem * var(--widget-font-scale));
    font-weight: 500;
    cursor: pointer;
    color: var(--color-text-primary);
    border-radius: 6px;
    transition: background 0.15s ease;
}

.calendar-nav:hover {
    background: rgba(0, 0, 0, 0.07);
}


/* ----------------------------------------------
   WEEKDAY NAMES ROW
   ---------------------------------------------- */

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-xs);
    font-size: calc(0.75rem * var(--widget-font-scale));
    color: var(--color-text-secondary);
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.03em;
}


/* ----------------------------------------------
   MONTH GRID
   ---------------------------------------------- */

.calendar-grid {
    /* Month grid fills remaining space in the widget */
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-xs);
    width: 100%;
    height: 100%;
    /* 6 fixed-height rows that do NOT stretch to fit content */
    grid-auto-rows: minmax(0, 1fr);
}


/* ----------------------------------------------
   DAY CELLS
   ---------------------------------------------- */

.calendar-day-cell {
    background: rgba(255, 255, 255, 0.65);
    border-radius: 8px;
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 48px;
    position: relative;
    /* Anything that overflows the fixed-height cell gets clipped */
    overflow: hidden;
}

.calendar-day-cell--outside {
    opacity: 0.40;
}

.calendar-day-cell--today {
    background: rgba(255, 255, 255, 0.9);
    outline: 2px solid var(--color-accent);
}

.calendar-day-number {
    font-size: 0.75rem;          /* Safari minimum, safe */
    font-weight: 600;
    color: var(--color-text-primary);

    transform: scale(0.60);      /* ← shrink visually */
    transform-origin: top left;  /* keep alignment correct */
    display: inline-block;       /* required for transform */
}

/* ----------------------------------------------
   EVENTS CONTAINER + PILLS
   ---------------------------------------------- */

/* Container that holds multiple event pills */
.calendar-day-events {
    margin-top: var(--space-xs);

    /* Base size for the row; pills shrink their own text further */
    font-size: calc(0.7rem * var(--widget-font-scale));
    line-height: 1.2;
    color: var(--color-text-secondary);

    display: flex;
    flex-direction: column;
    gap: 2px;

    /* Show several tiny pills, clip the rest without growing the row */
    max-height: calc(6 * 1.0em); /* roughly ~6 pill strips */
    overflow: hidden;
}

/* Individual event pill – fixed-height strip */
.calendar-event-pill {
    display: flex;
    align-items: center;

    /* Fixed pill size so text scaling doesn’t change the box */
    height: 12px;

    border-radius: 3px;
    padding: 0 3px;

    /* Default bg if no color given; overwritten per-event via inline style */
    background: rgba(0, 0, 0, 0.15);
    color: #ffffff;

    white-space: nowrap;
    overflow: hidden;
}


/* The TEXT inside the pill – actually shrunk */
.calendar-event-pill-text {
    display: inline-block;
    font-weight: 800;
    transform-origin: left center;

    /* 🔥 This is where the visual “4–5pt” effect comes from */
    transform: scale(0.45);

    line-height: 1;
    /* No extra letterspacing; more characters visible */
    letter-spacing: 0;
}

/* We keep this hook but don't recolor the text container itself;
   pills carry their own accent colors. */
.calendar-day-cell--has-events .calendar-day-events {
    /* No color change needed – pills are already colored. */
}


/* ----------------------------------------------
   META LINE (Bottom)
   ---------------------------------------------- */

.calendar-meta {
    margin-top: var(--space-sm);
    font-size: calc(0.75rem * var(--widget-font-scale));
    color: var(--color-text-secondary);
    text-align: right;
}


/* ----------------------------------------------
   MODE OVERRIDES
   ---------------------------------------------- */

/* MINI MODE – calendar is usually hidden completely */
.widget--mode-mini .widget-calendar {
    display: none;
}

/* COMPACT MODE */
.widget--mode-compact .calendar-day-number {
    font-size: calc(0.7rem * var(--widget-font-scale));
}

.widget--mode-compact .calendar-day-cell {
    padding: var(--space-xs);
}

/* STANDARD MODE – defaults are generally fine */

/* EXPANDED MODE – more breathing room */
.widget--mode-expanded .calendar-day-cell {
    padding: var(--space-md);
}

.widget--mode-expanded .calendar-day-number {
    font-size: calc(1rem * var(--widget-font-scale));
}

.widget--mode-expanded .calendar-weekdays {
    font-size: calc(0.9rem * var(--widget-font-scale));
}