/* ==========================================================================
   DIARY — Timeline + Entry Form
   ========================================================================== */

/* ---- Page layout ---- */

.diary-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

@media (max-width: 480px) {
    .diary-page {
        padding: 1.5rem 0.75rem;
    }
}

/* ---- Page head ---- */

.diary-page-head {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.diary-page-head h1 {
    font-weight: 500;
    font-size: 2rem;
    line-height: 1;
    color: var(--white);
}

@media (max-width: 480px) {
    .diary-page-head h1 {
        font-size: 1.5rem;
    }
}

/* ---- Month navigation ---- */

.month-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.month-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--grape);
    background: var(--darkestGrape);
    color: var(--grape);
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    transition:
        border-color 0.2s ease,
        color 0.2s ease,
        background-color 0.2s ease;
}

.month-nav-btn:hover {
    border-color: var(--lightMint);
    color: var(--lightMint);
    background-color: var(--darkestestGrape);
}

.month-nav-btn--disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.month-nav-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lightestGrape);
    letter-spacing: 0.02em;
    min-width: 8rem;
    text-align: center;
}

/* ---- Date groups ---- */

.date-group {
    margin-bottom: 1.5rem;
}

.date-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--grape);
    letter-spacing: 0.06em;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--darkestGrape);
}

.date-entries {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ---- Diary entry card ---- */

.entry-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--darkestGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 12px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease;
}

.entry-card:hover {
    border-top-color: var(--lightGrape);
    border-right-color: var(--lightGrape);
    border-bottom-color: var(--lightGrape);
}

.entry-top-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.skin-row-label {
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--grape);
}

/* Sentiment — left border accent (AI-processed entries only) */
.entry-card--sentiment-very-positive { border-left: 3px solid var(--mint); }
.entry-card--sentiment-positive      { border-left: 3px solid var(--lightMint); }
.entry-card--sentiment-neutral       { border-left: 3px solid var(--darkerGrape); }
.entry-card--sentiment-negative      { border-left: 3px solid var(--lightRed); }
.entry-card--sentiment-very-negative { border-left: 3px solid var(--darkRed); }

/* Skin score dots — read-only (timeline) */
.skin-score {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
}

.skin-score .score-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--darkerGrape);
    border: 1px solid var(--darkerGrape);
}

.skin-score .score-dot--filled {
    background-color: var(--lightMint);
    border-color: var(--lightMint);
}

.entry-text {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--lightestGrape);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.entry-tags {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.entry-tag {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--lightGrape);
    border: 1px solid var(--darkerGrape);
    border-radius: 999px;
    padding: 0.125rem 0.5rem;
    line-height: 1.6;
}

.ai-zone {
    border-top: 1px dashed var(--darkerGrape);
    padding-top: 0.625rem;
}

.ai-obs-pills-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.ai-obs-pill {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--lightMint);
    border: 1px solid var(--darkestGrape);
    border-radius: 999px;
    padding: 0.125rem 0.5rem;
    line-height: 1.6;
}

.entry-products {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.entry-products-slot {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
    line-height: 1.5;
}

.entry-products-slot-label {
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--grape);
    flex-shrink: 0;
    min-width: 1.5rem;
}

.entry-products-names {
    font-size: 0.75rem;
    color: var(--darkGrape);
}

.entry-products-name--skipped {
    text-decoration: line-through;
    opacity: 0.5;
}

.entry-products-sep {
    color: var(--darkerGrape);
}

/* ---- Routine event row (timeline) ---- */

.routine-event {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0 0.625rem 0.875rem;
    border-left: 2px solid var(--darkerGrape);
}

.routine-event-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
}

.routine-event-icon--added {
    color: var(--lightMint);
}

.routine-event-icon--removed {
    color: var(--lightRed);
}

.routine-event-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--lightGrape);
    line-height: 1.4;
}

/* ---- Entry form ---- */

.diary-form-section {
    max-width: 640px;
    margin: 0 auto;
}

.skin-section-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lightestGrape);
    margin-bottom: 0.75rem;
}

/* Skin score dots in the form (larger, clickable) */
.score-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.score-label-end {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--grape);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 2rem;
}

.score-label-end--left {
    text-align: right;
}

.score-label-end--right {
    text-align: left;
}

.score-dots {
    display: flex;
    flex-direction: row;
    gap: 0.625rem;
}

.score-dots .score-dot {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    border: 2px solid var(--darkerGrape);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease;
}

.score-dots .score-dot:hover {
    border-color: var(--lightGrape);
}

.score-dots .score-dot--filled {
    background-color: var(--lightMint);
    border-color: var(--lightMint);
}

.score-dots .score-dot--filled:hover {
    background-color: var(--mint);
    border-color: var(--mint);
}

/* ---- Product list (form) ---- */

.product-slot-section {
    margin-bottom: 0.5rem;
}

.product-slot-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--grape);
    padding: 0.5rem 0 0.25rem;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.product-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--darkestGrape);
}

.product-row:last-of-type {
    border-bottom: none;
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lightestGrape);
    line-height: 1.3;
}

.product-brand {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--grape);
    line-height: 1.3;
}

.product-row--skipped .product-name,
.product-row--skipped .product-brand {
    opacity: 0.5;
}

.product-row--skipped .toggle-label-text {
    color: var(--lightRed);
}

.toggle-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.toggle-label-text {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--grape);
}

/* ---- Form separator ---- */

.form-separator {
    width: 100%;
    height: 1px;
    background-color: var(--darkestGrape);
    border: none;
    margin: 0.5rem 0 1.25rem;
}

/* ---- Submit/delete button spacing ---- */

.diary-submit-btn {
    margin-top: 2rem;
}

.diary-delete-btn {
    margin-top: 0.75rem;
}

/* ---- Form errors ---- */

.form-errors {
    background-color: var(--darkestGrape);
    border: 1px solid var(--lightRed);
    border-radius: 8px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
}

.form-error-message {
    font-size: 0.875rem;
    color: var(--lightRed);
    margin: 0 0 0.375rem;
}

.field-error {
    display: block;
    font-size: 0.8125rem;
    color: var(--lightRed);
    margin-top: 0.375rem;
}

/* ---- Empty states ---- */

.diary-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 4rem 1rem;
    text-align: center;
    color: var(--grape);
}

.diary-empty-state p {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
}

.diary-empty-products {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--grape);
    padding: 1rem 0;
}

/* ---- Drawer product row: 3-position sliding toggle ---- */

/*
 * Mirrors the 2-state .toggle-track / .toggle-thumb pattern from inputs.css.
 *
 * Three data-state values on .slot-toggle:
 *   "am"   — thumb slides to the left  (AM position)
 *   "none" — thumb rests in the centre (default, nothing submitted)
 *   "pm"   — thumb slides to the right (PM position)
 *
 * Sizing derived from the 2-state toggle:
 *   Track height  : 1.5rem  (identical)
 *   Thumb diameter: 1.125rem (identical)
 *   Inset         : 3px     (identical)
 *   Track width   : 5rem    (widened to fit 3 equidistant stops)
 *
 * Travel per step = (5rem - 2×3px - 1.125rem) / 2 ≈ 1.75rem
 *   AM   → translateX(0)
 *   none → translateX(1.75rem)
 *   PM   → translateX(3.5rem)
 *
 * Colour language:
 *   AM   — mint         (matches the form's primary active colour)
 *   PM   — lighterGrape (muted mauve-lavender; reads "evening/dusk" without
 *                        veering into warm-red alarm territory)
 *   none — darkerGrape  (inactive, same as 2-state off state)
 */

.slot-toggle-wrapper {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    gap: 0.375rem;
}

/* AM / PM labels flanking the track */
.slot-toggle-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--darkerGrape);
    transition: color 0.25s ease;
    min-width: 1.75rem;
    user-select: none;
}

.slot-toggle-label--am {
    text-align: right;
}

.slot-toggle-label--pm {
    text-align: left;
}

/* Highlight the active label */
.slot-toggle-wrapper:has(.slot-toggle[data-state="am"]) .slot-toggle-label--am {
    color: var(--lightMint);
}

.slot-toggle-wrapper:has(.slot-toggle[data-state="pm"]) .slot-toggle-label--pm {
    color: var(--lighterGrape);
}

/* The button itself is an invisible wrapper around the visual track */
.slot-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0;
    color: transparent;
}

.slot-toggle:focus-visible .slot-toggle__track {
    outline: 2px solid var(--lightMint);
    outline-offset: 2px;
}

/* Track */
.slot-toggle__track {
    position: relative;
    display: inline-block;
    width: 5rem;
    height: 1.5rem;
    border-radius: 999px;
    background-color: var(--darkerGrape);
    transition: background-color 0.25s ease;
}

/* Thumb — starts at AM (left) by default when data-state="am" */
.slot-toggle__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    background-color: var(--white);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease;
    /* Default: data-state="none" — centre position */
    transform: translateX(1.75rem);
}

/* AM: thumb left */
.slot-toggle[data-state="am"] .slot-toggle__thumb {
    transform: translateX(0);
}

/* PM: thumb right */
.slot-toggle[data-state="pm"] .slot-toggle__thumb {
    transform: translateX(3.5rem);
}

/* Track colour by state */
.slot-toggle[data-state="am"] .slot-toggle__track {
    background-color: var(--darkestGrape);
    box-shadow: inset 0 0 0 1px var(--lightMint);
}

.slot-toggle[data-state="pm"] .slot-toggle__track {
    background-color: var(--darkestGrape);
    box-shadow: inset 0 0 0 1px var(--lighterGrape);
}

/* Thumb colour follows slot */
.slot-toggle[data-state="am"] .slot-toggle__thumb {
    background-color: var(--lightMint);
}

.slot-toggle[data-state="pm"] .slot-toggle__thumb {
    background-color: var(--lighterGrape);
}

/* Hover — darken track slightly when not in an active state */
.slot-toggle:hover .slot-toggle__track {
    background-color: var(--darkGrape);
}

.slot-toggle[data-state="am"]:hover .slot-toggle__track,
.slot-toggle[data-state="pm"]:hover .slot-toggle__track {
    background-color: var(--darkestGrape);
}

/* Dim product name/brand when a slot is active */
.product-row--drawer.product-row--slot-active .product-name {
    color: var(--lighterGrape);
}

.product-row--drawer.product-row--slot-active .product-brand {
    color: var(--lightGrape);
}
