/* Dynamic Island: Study HUD */

/* Docked as a real column beside the conversation. As a fixed overlay it sat
   on top of the messages and forced .chat-scroll to reserve blank safe-zone
   padding to keep text out from under it. */
/* The side column has room for the whole panel, so the disclosure is inert
   here: the summary is hidden and the content shows regardless of open state.
   It only becomes a real toggle at the narrow breakpoint. */
.island-summary {
    display: none;
}

.island-disclosure > .dynamic-island {
    display: flex;
}

.dynamic-island-container {
    grid-area: focus;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* The panel sizes to its content and the page scrolls as a whole. A nested
       scroll container here produced a second vertical scrollbar beside the
       chat's own, on a box whose content already fit inside it. */
    overflow: visible;
    padding: var(--s-3) 0 var(--s-3) var(--s-3);
}

.dynamic-island {
    /* In-flow panel: it sits beside the conversation rather than hovering over
       it, so it needs no lift, halo or gradient border to separate it. */
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--r-l);
    padding: var(--s-3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    color: var(--ink);
    width: 100%;
    transition: border-color var(--dur-fast) var(--ease-out);
    user-select: none;
    -webkit-user-select: none;
    /* Prevents double-click text selection interference */
}

/* Hover effect for interactivity */
.dynamic-island:hover {
    border-color: var(--teal);
}

.island-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 10px var(--teal);
    flex-shrink: 0;
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }

    100% {
        opacity: 0.5;
        transform: scale(1);
    }
}

.island-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.island-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    margin-bottom: 2px;
}

.island-text {
    font-size: var(--text-sm);
    font-weight: 500;
    color: white;
    white-space: normal;
    /* Wrap text */
    word-break: break-word;
    /* Prevent overflow */
    line-height: 1.4;
}

.island-controls {
    display: flex;
    gap: var(--s-2);
    /* Hidden by default, shown on expand */
    opacity: 0.5;
    transition: opacity var(--dur-fast);
}

.dynamic-island:hover .island-controls {
    opacity: 1;
}

/* Batched items list */
.island-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    width: 100%;
}

.island-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--s-1);
}

/* Counts the rows the narrow-screen cap hides. The side column shows every
   row, so there is nothing to count until that cap applies. */
.island-more {
    display: none;
}

.island-item {
    padding: var(--s-2) var(--s-3);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--r-m);
    display: flex;
    justify-content: space-between;
    /* To separate text and button */
    align-items: center;
    gap: var(--s-2);
    font-size: var(--text-sm);
    transition: all var(--dur-fast);
    border-left: 2px solid transparent;
}

.island-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* State indicators for island items */
.island-item .state-indicator {
    font-size: 14px;
    opacity: 0.8;
    flex-shrink: 0;
}

.island-item .island-score {
    font-size: var(--text-xs);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

/* State-based styling for island items - intensity/saturation variations */
/* Border color is always the type's accent color */
.island-item.state-new,
.island-item.state-started,
.island-item.state-activated,
.island-item.state-competent,
.island-item.state-mastered,
.island-item.state-perfected {
    border-left-color: var(--accent-color);
}

/* New: Low opacity, low saturation */
.island-item.state-new {
    opacity: 0.6;
    filter: saturate(0.5);
}

/* Started: Slightly increased */
.island-item.state-started {
    opacity: 0.75;
    filter: saturate(0.7);
}

/* Activated: Normal */
.island-item.state-activated {
    opacity: 0.9;
    filter: saturate(1);
}

/* Competent: Enhanced saturation, subtle glow */
.island-item.state-competent {
    opacity: 1;
    filter: saturate(1.2) drop-shadow(0 0 2px var(--accent-color));
}

/* Mastered: High saturation, medium glow */
.island-item.state-mastered {
    opacity: 1;
    filter: saturate(1.4) brightness(1.05) drop-shadow(0 0 4px var(--accent-color));
}

/* Perfected: Maximum saturation, intense glow, gold star */
.island-item.state-perfected {
    opacity: 1;
    filter: saturate(1.6) brightness(1.1) drop-shadow(0 0 6px var(--accent-color));
}

.island-item.state-perfected .state-indicator {
    color: rgba(255, 215, 0, 1);
    filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.8));
}

.island-item.state-perfected .island-score {
    color: rgba(255, 215, 0, 1);
}

/* Pulse via opacity on a glow pseudo-element rather than animating `filter`:
   animated drop-shadow re-runs the filter pipeline on every frame. */
.island-item.state-perfected {
    position: relative;
}

.island-item.state-perfected::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    box-shadow: 0 0 8px var(--accent-color), 0 0 16px var(--accent-color);
    opacity: 0;
    pointer-events: none;
    animation: island-perfected-pulse 2s ease-in-out infinite;
}

@keyframes island-perfected-pulse {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

.island-text.large {
    font-size: var(--text-lg);
    font-weight: 600;
}

.island-plan-step {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2);
}

.check-icon {
    font-size: var(--text-xl);
}

.island-btn-small {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: var(--text-xs);
    opacity: 0;
    /* Hidden until hover */
    transition: opacity var(--dur-fast);
}

.island-item:hover .island-btn-small {
    opacity: 1;
}

.island-btn-small:hover {
    color: white;
    transform: scale(1.1);
}

/* Light Theme Overrides */
/* The island is usually dark, but if we want it light-themed: */
/* For now, we keep it dark "status bar" style even in light mode for contrast */

/* Hover-only controls never reveal on touch devices. */
@media (hover: none) {
    .island-btn-small {
        opacity: 1;
    }
}

/* ---------------------------------------------------------------
   Below the two-column threshold there is no room for a side column,
   so the focus panel becomes a short band above the conversation.
   --------------------------------------------------------------- */
@media (max-width: 900px) {
    .dynamic-island-container {
        padding: var(--s-2) var(--s-2) 0;
        flex: 0 0 auto;
    }

    .dynamic-island {
        gap: var(--s-2);
        padding: var(--s-2);
    }

    .island-item {
        padding: var(--s-1) var(--s-2);
        font-size: var(--text-xs);
    }

    .island-list {
        gap: var(--s-1);
    }

    .island-text {
        font-size: var(--text-xs);
    }

    /* The 🎯 renders 19px tall and holds each quest row open to 26px even
       though its label is 14px; sizing the emoji down collapses the row to
       the height of the text beside it. */
    .quest-icon {
        font-size: var(--text-xs);
    }

    .island-quests {
        gap: var(--s-1);
    }

    /* The conversation is the app: the band stays a short strip above it. Only
       the first two review rows and two quests are shown; `.island-more` counts
       the rest, so nothing vanishes without a trace. Kept as display:none
       rather than an inner scroller - a second scrollbar beside the chat's own
       is what this panel had before, and it accomplished nothing. */
    /* nth-of-type counts every sibling div, and .island-header is one, so the
       cap is expressed relative to the header rather than by raw position. */
    .island-item:nth-of-type(n + 4),
    .island-quest-item:nth-of-type(n + 4) {
        display: none;
    }

    /* Collapsed by default: the conversation starts directly under the header
       instead of below a study panel. The summary is one tappable line; the
       panel opens in place and pushes the chat down only while it is open. */
    .island-summary {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: var(--s-2);
        padding: var(--s-2) var(--s-3);
        background: var(--surface);
        border: 1px solid rgba(255, 255, 255, 0.07);
        border-radius: var(--r-l);
        cursor: pointer;
        list-style: none;
        user-select: none;
        -webkit-user-select: none;
    }

    /* Safari draws its own disclosure triangle through ::-webkit-details-marker
       and ignores list-style. */
    .island-summary::-webkit-details-marker {
        display: none;
    }

    .island-summary-count {
        font-size: var(--text-xs);
        font-weight: 600;
        color: var(--teal);
    }

    /* The marker rotates to point down when the panel is open. */
    .island-summary::after {
        content: "›";
        margin-left: auto;
        color: var(--ink-soft);
        transform: rotate(90deg);
        transition: transform var(--dur-fast) var(--ease-out);
    }

    .island-disclosure[open] .island-summary::after {
        transform: rotate(-90deg);
    }

    .island-disclosure[open] .island-summary {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        margin-bottom: 0;
    }

    .island-disclosure[open] > .dynamic-island {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-top: none;
    }

    /* Quests run one per full-width row, so two of them plus a label cost more
       height than the whole review list. They flow inline instead: the 🎯 and
       its text sit on a shared line and wrap only when they must. */
    .island-quests {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: var(--s-1) var(--s-2);
    }

    .island-quests .island-header {
        margin-bottom: 0;
    }

    .island-quest-item {
        display: inline-flex;
        align-items: baseline;
        gap: 2px;
    }

    /* The 🎯 repeats on every row and the label above already frames them. */
    .island-quest-item .quest-icon {
        display: none;
    }

    .island-more {
        display: inline;
        font-size: var(--text-xs);
        font-weight: 600;
        color: var(--teal);
        letter-spacing: 0.02em;
    }
}