/* ================================================================
   Light — effects.css
   Visual polish: scrollbars, selection, transitions, animations,
   entrance effects, micro-interactions.
   ================================================================ */

/* --- Selection & Scrollbars ---------------------------------------- */
::selection {
    background: rgba(37, 99, 235, 0.14);
    color: var(--ink);
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(12, 18, 34, 0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(12, 18, 34, 0.22); }

/* --- Base Transitions ---------------------------------------------- */
.section-link { transition: color 0.15s ease; }
.section-link:hover { color: var(--accent-hover); }

.question-index-link { transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; }
.question-index-link:hover { transform: scale(1.08); }

.answer-option-row { transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease; }
.answer-option-row:hover:not(.is-disabled) { transform: translateX(4px); }

.content-outline-link { transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease; }
.dfb-nav-link { transition: color 0.12s ease, background 0.12s ease; }

.btn {
    transition: background 0.15s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }

.notice-bar { transition: opacity 0.2s ease, transform 0.2s ease; }

/* --- Card Hover Effects -------------------------------------------- */
.quick-link-card {
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.quick-link-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.timeline-item {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.timeline-item:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.package-line {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.package-line:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.question-stage { transition: border-color 0.2s ease, box-shadow 0.2s ease; }

.hero-entry, .df-entry {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.25s ease;
}
.hero-entry:hover, .df-entry:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-3px);
}

.stat-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.feature-band {
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.feature-band:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.catalog-line {
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.catalog-line:hover {
    border-color: var(--border-strong);
    background: var(--surface-alt);
    transform: translateX(3px);
}

.info-rail-section {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.info-rail-section:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
}

/* --- Copy Button --------------------------------------------------- */
a[data-copy-text] { cursor: pointer; }
a[data-copy-text].is-copied { color: var(--positive); }

/* --- Progress Bar Animation ---------------------------------------- */
.progress-bar { animation: progress-fill 0.8s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes progress-fill {
    from { width: 0; }
}

/* --- Fade / Reveal Animations -------------------------------------- */
.fade.show { animation: fade-in 0.2s ease; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes reveal-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes reveal-scale {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes reveal-left {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Scroll-triggered Entrance ------------------------------------- */
.question-stage,
.timeline-item,
.catalog-line,
.info-rail-section,
.stat-card,
.hero-entry,
.df-entry,
.package-line,
.feature-band {
    opacity: 0;
    transform: translateY(16px);
}

.question-stage.is-revealed,
.timeline-item.is-revealed,
.info-rail-section.is-revealed,
.stat-card.is-revealed,
.hero-entry.is-revealed,
.df-entry.is-revealed,
.package-line.is-revealed,
.feature-band.is-revealed {
    animation: reveal-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.catalog-line.is-revealed {
    animation: reveal-left 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.surface.is-revealed {
    animation: reveal-scale 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.question-stage:nth-child(1) { animation-delay: 0s; }
.question-stage:nth-child(2) { animation-delay: 0.05s; }
.question-stage:nth-child(3) { animation-delay: 0.1s; }
.question-stage:nth-child(4) { animation-delay: 0.15s; }
.question-stage:nth-child(5) { animation-delay: 0.2s; }

.catalog-line:nth-child(1) { animation-delay: 0s; }
.catalog-line:nth-child(2) { animation-delay: 0.04s; }
.catalog-line:nth-child(3) { animation-delay: 0.08s; }
.catalog-line:nth-child(4) { animation-delay: 0.12s; }
.catalog-line:nth-child(5) { animation-delay: 0.16s; }

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.18s; }

/* --- Header animation ---------------------------------------------- */
.dfb-header {
    animation: header-slide-down 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes header-slide-down {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Page head entrance -------------------------------------------- */
.page-head {
    animation: reveal-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

.competition-hero {
    animation: reveal-scale 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.05s backwards;
}

/* --- Breadcrumbs --------------------------------------------------- */
.breadcrumbs {
    animation: fade-in 0.3s ease 0.05s backwards;
}

/* --- Chip subtle pulse on hover ------------------------------------ */
.chip {
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.chip:hover {
    transform: scale(1.04);
}

/* --- Brand mark pulse ---------------------------------------------- */
.dfb-brand-mark {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dfb-brand:hover .dfb-brand-mark {
    transform: scale(1.06);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --- Question status legend dot pulse ------------------------------ */
.question-status-legend .dot {
    transition: transform 0.2s ease;
}
.question-status-legend span:hover .dot {
    transform: scale(1.4);
}

/* --- Loading / spinner --------------------------------------------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.is-loading::after {
    content: "";
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
    vertical-align: middle;
}

/* --- Focus rings --------------------------------------------------- */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* --- Smooth page transitions (for turbo/etc if added later) -------- */
.dfb-page {
    animation: page-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes page-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ================================================================
   Cross-page consistency layer
   ================================================================ */

body.theme-light {
    --theme-panel-bg: rgba(255, 255, 255, 0.92);
    --theme-panel-muted-bg: rgba(247, 250, 255, 0.88);
    --theme-panel-border: rgba(203, 213, 225, 0.55);
    --theme-panel-shadow: 0 20px 44px rgba(15, 23, 42, 0.08);
    --theme-panel-shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.04);
    --theme-card-radius: 14px;
    --theme-row-radius: 11px;
    --theme-page-bottom: clamp(44px, 6vw, 82px);
}

body.theme-light .dfb-page {
    padding-bottom: var(--theme-page-bottom);
}

body.theme-light .dfb-page > .dfb-container > :last-child {
    margin-bottom: clamp(22px, 4vw, 48px);
}

body.theme-light .breadcrumbs {
    margin-bottom: 14px;
    color: var(--ink-muted);
    font-size: 13px;
    line-height: 1.7;
}

body.theme-light .breadcrumbs a {
    color: var(--ink-3);
}

body.theme-light .breadcrumbs strong {
    color: var(--ink);
    font-weight: 650;
}

body.theme-light .page-head,
body.theme-light header.page-head,
body.theme-light .page-head-compact,
body.theme-light header.page-head-compact {
    margin-bottom: clamp(18px, 2.4vw, 30px);
    padding-top: clamp(10px, 1.4vw, 18px);
    padding-bottom: clamp(10px, 1.4vw, 18px);
}

body.theme-light .page-title {
    max-width: 920px;
    color: var(--ink);
    font-size: clamp(28px, 3.2vw, 44px);
    line-height: 1.12;
    letter-spacing: -0.045em;
}

body.theme-light .page-lead {
    max-width: 780px;
    margin-top: 10px;
    color: var(--ink-3);
    font-size: clamp(15px, 1.35vw, 18px);
    line-height: 1.78;
}

body.theme-light .page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 12px;
    color: var(--ink-muted);
    font-size: 13px;
}

body.theme-light .section-head,
body.theme-light .panel-head,
body.theme-light .catalog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

body.theme-light .section-title,
body.theme-light .dash-section-title,
body.theme-light .catalog-title,
body.theme-light .panel-head h2,
body.theme-light .panel-head h3 {
    color: var(--ink);
    line-height: 1.25;
    letter-spacing: -0.02em;
}

body.theme-light :is(.surface, .surface-muted, .surface-plain, .workspace-panel, .auth-panel, .quick-link-card, .timeline-item, .package-line, .feature-band, .info-rail-section, .stat-card, .catalog-line, .writeup-card, .notice-bar, .empty-state, .df-panel, .doc-rail, .doc-outline-panel, .writeup-meta-card, .info-copy-card, .query-bar, .compact-query-bar) {
    border-color: var(--theme-panel-border);
    border-radius: var(--theme-card-radius);
    box-shadow: var(--theme-panel-shadow-soft);
}

body.theme-light :is(.page-head, .competition-hero, .surface, .surface-muted, .surface-plain, .workspace-panel, .quick-link-card, .timeline-item, .package-line, .feature-band, .info-rail-section, .writeup-card, .empty-state, .df-panel, .query-bar, .compact-query-bar) {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

body.theme-light :is(.surface, .surface-plain, .workspace-panel, .auth-panel, .quick-link-card, .timeline-item, .package-line, .feature-band, .info-rail-section, .stat-card, .writeup-card, .notice-bar, .empty-state, .df-panel, .doc-rail, .doc-outline-panel, .writeup-meta-card, .info-copy-card, .query-bar, .compact-query-bar) {
    background: var(--theme-panel-bg);
}

body.theme-light :is(.surface-muted, .catalog-line) {
    background: var(--theme-panel-muted-bg);
}

body.theme-light :is(.catalog-line, .writeup-card, .quick-link-card, .package-line, .timeline-item, .info-link-card) {
    border-radius: var(--theme-row-radius);
}

body.theme-light :is(.catalog-line, .writeup-card, .quick-link-card, .package-line, .timeline-item, .info-link-card):hover {
    border-color: var(--border-strong);
    box-shadow: var(--theme-panel-shadow);
    background: rgba(247, 250, 255, 0.95);
    transform: translateY(-1px) !important;
}

body.theme-light :is(.surface-pad-lg, .auth-panel, .workspace-panel .panel-body) {
    padding: clamp(18px, 2.1vw, 28px);
}

body.theme-light .catalog {
    display: grid;
    gap: 12px;
}

body.theme-light .catalog-line {
    padding: clamp(14px, 1.6vw, 20px);
}

body.theme-light .catalog-title,
body.theme-light .catalog-title-link,
body.theme-light .writeup-card-title,
body.theme-light .card-title-link {
    font-weight: 750;
    letter-spacing: -0.018em;
}

body.theme-light .catalog-summary,
body.theme-light .writeup-card-lead,
body.theme-light .section-summary {
    color: var(--ink-3);
    line-height: 1.72;
}

body.theme-light :is(.query-bar, .compact-query-bar, .query-grid, .query-grid-compact) {
    gap: 12px;
    margin-bottom: clamp(16px, 2vw, 24px);
}

body.theme-light :is(.form-control, .form-select, .query-control) {
    min-height: 42px;
    border-color: var(--theme-panel-border);
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    font-size: 14px;
}

body.theme-light textarea.form-control {
    min-height: 132px;
    line-height: 1.68;
}

body.theme-light :is(.form-control, .form-select, .query-control):focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08), inset 0 1px 2px rgba(37, 99, 235, 0.06);
}

body.theme-light .content-shell,
body.theme-light .doc-index,
body.theme-light .profile-layout,
body.theme-light .auth-layout {
    gap: clamp(18px, 2.4vw, 30px);
    align-items: start;
}

body.theme-light .aside-stack {
    display: grid;
    gap: 16px;
}

@media (min-width: 1025px) {
    body.theme-light :is(.doc-rail, .aside-stack, .profile-side) {
        position: sticky;
        top: 92px;
    }
}

@media (max-width: 768px) {
    body.theme-light {
        --theme-card-radius: 12px;
        --theme-row-radius: 10px;
    }

    body.theme-light .dfb-page {
        padding-bottom: 42px;
    }

    body.theme-light .breadcrumbs {
        margin-bottom: 10px;
        font-size: 12px;
    }

    body.theme-light .page-head,
    body.theme-light header.page-head,
    body.theme-light .page-head-compact,
    body.theme-light header.page-head-compact {
        margin-bottom: 16px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    body.theme-light .page-title {
        font-size: clamp(24px, 8vw, 32px);
        line-height: 1.18;
    }

    body.theme-light .page-lead {
        font-size: 14px;
        line-height: 1.7;
    }

    body.theme-light .section-head,
    body.theme-light .panel-head,
    body.theme-light .catalog-head:not(.catalog-head-inline) {
        flex-direction: column;
        align-items: stretch;
    }

    body.theme-light .catalog-head.catalog-head-inline {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
    }

    body.theme-light :is(.surface-pad-lg, .surface-pad, .auth-panel, .workspace-panel .panel-body) {
        padding: 16px;
    }

    body.theme-light .catalog-line {
        padding: 14px;
    }

    body.theme-light .content-shell,
    body.theme-light .doc-index,
    body.theme-light .profile-layout,
    body.theme-light .auth-layout {
        gap: 16px;
    }
}
