/* ==========================================================================
   Componentes
   ========================================================================== */

/* ---------- Button ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    height: 2.5rem;
    padding-inline: 1rem;
    border-radius: 999px;

    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;

    cursor: pointer;
    transform: scale(1);
    transition:
        transform 250ms cubic-bezier(0, 0, 0.2, 1),
        background-color 100ms cubic-bezier(0, 0, 0.2, 1),
        box-shadow 100ms cubic-bezier(0, 0, 0.2, 1);

    @media (min-width: 48rem) {
        height: 2.25rem;
    }

    @media (pointer: coarse) {
        min-height: 44px;
    }

    &:active {
        transform: scale(0.97);
    }

    &:focus-visible {
        outline: 2px solid var(--color-accent);
        outline-offset: 2px;
    }

    &.button--lg {
        height: 2.75rem;

        font-size: 1rem;

        @media (min-width: 48rem) {
            height: 2.5rem;
        }
    }

    &.button--primary {
        background: var(--color-accent);
        color: var(--color-accent-foreground);

        &:hover {
            background: color-mix(in oklab, var(--color-accent) 90%, black 10%);
        }
    }

    &.button--tertiary {
        background: var(--color-default);
        color: var(--color-foreground);

        &:hover {
            background: color-mix(in oklab, var(--color-default) 80%, black 5%);
        }
    }

    &.button--ghost {
        background: transparent;
        color: var(--color-muted);

        &:hover {
            background: var(--color-default);
        }
    }

    &.button--full-width {
        width: 100%;
    }

    &.button--icon {
        aspect-ratio: 1;
        padding-inline: 0;

        svg {
            width: 1.25rem;
            height: 1.25rem;
        }
    }
}

/* ---------- Hero: entrada com fade + subida ---------- */

.celebrate-stagger {
    > * {
        opacity: 1;
        transform: translateY(0);
        transition:
            opacity 380ms cubic-bezier(0.23, 1, 0.32, 1),
            transform 380ms cubic-bezier(0.23, 1, 0.32, 1);

        &:nth-child(2) {
            transition-delay: 60ms;
        }

        &:nth-child(3) {
            transition-delay: 120ms;
        }

        @starting-style {
            opacity: 0;
            transform: translateY(10px);
        }
    }
}

/* ---------- Reveal ao rolar (nativo, com fallback via classe) ---------- */

@keyframes reveal-rise {
    from {
        opacity: 0;
        transform: translateY(1.25rem);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .reveal {
            animation: reveal-rise linear both;
            animation-timeline: view();
            animation-range: entry 8% cover 30%;
        }
    }
}

@supports not (animation-timeline: view()) {
    .reveal {
        opacity: 0;
        transform: translateY(1.25rem);
        transition:
            opacity 500ms cubic-bezier(0.23, 1, 0.32, 1),
            transform 500ms cubic-bezier(0.23, 1, 0.32, 1);

        &.reveal--visible {
            opacity: 1;
            transform: none;
        }
    }
}

/* ---------- Folder card (Hero) ---------- */

.folder-card {
    position: relative;

    width: 100%;
    border-radius: 1.5rem;

    background-image: url("../assets/detalhe-pasta.svg");
    background-repeat: no-repeat;
    background-position: top right;

    &.folder-card--red {
        background-color: var(--color-folder-red);
    }

    &.folder-card--green {
        background-color: var(--color-folder-green);
    }

    &.folder-card--orange {
        background-color: var(--color-folder-orange);
    }

    &.folder-card--purple {
        background-color: var(--color-folder-purple);
    }

    .folder-card__previews {
        position: relative;

        display: flex;
        overflow: hidden;

        height: 5rem;
    }

    .folder-card__footer {
        position: relative;

        display: flex;
        flex-direction: column;
        justify-content: center;

        height: 5rem;
        padding: 0.25rem 1rem;
        border-radius: 0 0 1.5rem 1.5rem;

        background: rgb(0 0 0 / 15%);
        color: #fff;

        .folder-card__name {
            font-size: 1.5rem;
            font-weight: 600;
        }

        .folder-card__count {
            opacity: 0.75;
            font-variant-numeric: tabular-nums;
        }
    }
}

.preview {
    position: absolute;
    top: 50%;

    width: 5.125rem;
    height: 4.5rem;
    max-width: 33.333%;
    padding: 0.5rem;
    border-radius: 0.5rem;

    background: #fff;

    @media (min-width: 48rem) {
        scale: 0.9;
    }

    &:nth-child(1) {
        right: 2rem;
        transform: rotate(-5deg);
    }

    &:nth-child(2) {
        right: 6rem;
        transform: rotate(14deg);
    }

    &:nth-child(3) {
        right: 10rem;
        transform: rotate(-6deg);
    }

    &:nth-child(4) {
        right: 14rem;
        transform: rotate(16deg);
    }

    &:nth-of-type(4) {
        @media (min-width: 48rem) {
            display: none;
        }
    }

    span {
        display: block;

        margin-bottom: 6px;
        height: 0.5rem;
        border-radius: 999px;

        background-color: #e3e3e3;

        &:nth-child(1) {
            width: 100%;
        }

        &:nth-child(2) {
            width: 80%;
        }

        &:nth-child(3) {
            width: 60%;
        }
    }
}

/* ---------- Steps (Como funciona) ---------- */

.step-list {
    display: flex;
    flex-direction: column;
}

.step {
    position: relative;

    display: grid;
    grid-template-columns: 3rem 1fr;
    gap: 0 1.25rem;

    padding-bottom: 2.5rem;

    @media (min-width: 40rem) {
        gap: 0 1.5rem;
    }

    &:last-child {
        padding-bottom: 0;
    }

    .step__connector {
        position: absolute;
        top: 3.5rem;
        bottom: 0;
        left: 1.5rem;

        border-left: 1px solid var(--color-border);
    }

    .step__icon {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 3rem;
        height: 3rem;
        border-radius: 999px;

        background: #fff;
        color: var(--color-accent);
        box-shadow: var(--shadow-surface);
    }

    .step__body {
        padding-top: 0.625rem;

        h3 {
            font-size: 1.25rem;
        }

        p {
            margin-top: 0.5rem;

            max-width: 52ch;
            line-height: 1.6;
            color: var(--color-muted);
        }
    }
}

/* ---------- Mode card (Modos de estudo) ---------- */

.mode-card {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;

    border-radius: 1.5rem;
    padding: 1.25rem;

    background: #fff;
    box-shadow: var(--shadow-surface);

    @media (min-width: 48rem) {
        padding: 1.5rem;
    }

    &.mode-card--flashcards {
        @media (min-width: 64rem) {
            grid-column: span 5;
            grid-row: span 2;
        }
    }

    &.mode-card--summary,
    &.mode-card--quiz {
        @media (min-width: 64rem) {
            grid-column: span 7;
        }
    }

    &.mode-card--mapa-mental {
        @media (min-width: 64rem) {
            grid-column: span 12;
        }
    }

    &.mode-card--timer {
        @media (min-width: 64rem) {
            grid-column: span 7;
        }
    }

    .mode-card__header {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .mode-card__icon {
        display: flex;
        flex-shrink: 0;
        align-items: center;
        justify-content: center;

        width: 2.25rem;
        height: 2.25rem;
        border-radius: 0.75rem;

        color: #fff;

        &.mode-card__icon--emerald {
            background: #10b981;
        }

        &.mode-card__icon--violet {
            background: #6d28d9;
        }

        &.mode-card__icon--orange {
            background: #ea580c;
        }

        &.mode-card__icon--cyan {
            background: #0092b8;
        }

        &.mode-card__icon--accent {
            background: var(--color-accent);
        }
    }

    .mode-card__title {
        font-weight: 600;
        font-size: 1rem;
    }

    .mode-card__subtitle {
        font-size: 0.75rem;
        color: var(--color-muted);
    }

    .mode-card__footer {
        font-size: 0.875rem;
        line-height: 1.6;
        color: var(--color-muted);
    }
}

.content-panel {
    border-radius: 1rem;
    padding: 1rem;

    &.content-panel--emerald {
        display: flex;
        flex: 1;
        flex-direction: column;
        gap: 1rem;

        background:
            radial-gradient(
                100% 100% at 50% 0%,
                var(--color-content-emerald) 0%,
                rgb(242 242 244 / 20%) 100%
            ),
            var(--color-page-bg);
    }

    &.content-panel--purple {
        background:
            radial-gradient(
                100% 100% at 50% 0%,
                var(--color-content-purple) 0%,
                rgb(242 242 244 / 20%) 100%
            ),
            var(--color-page-bg);
    }

    &.content-panel--orange {
        background:
            radial-gradient(
                100% 100% at 50% 0%,
                var(--color-content-orange) 0%,
                rgb(242 242 244 / 20%) 100%
            ),
            var(--color-page-bg);
    }

    &.content-panel--cyan {
        background:
            radial-gradient(
                100% 100% at 50% 0%,
                var(--color-content-cyan) 0%,
                rgb(242 242 244 / 20%) 100%
            ),
            var(--color-page-bg);

        img {
            display: block;
            width: 100%;
            height: auto;
        }
    }

    &.content-panel--accent {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;

        padding-block: 2rem;
        box-shadow: var(--shadow-surface);
    }
}

/* ---------- Flash card (flip 3D) ---------- */

.flashcard {
    position: relative;

    flex: 1;
    min-height: min(24rem, 50vh);

    perspective: 1200px;

    &.is-flipped .flashcard__inner {
        transform: rotateY(180deg);
    }

    .flashcard__inner {
        position: absolute;
        inset: 0;

        transform-style: preserve-3d;
        transition: transform 500ms ease-in-out;
    }

    .flashcard__face {
        position: absolute;
        inset: 0;

        display: flex;
        flex-direction: column;
        justify-content: space-between;

        padding: 2rem 1rem;
        border-radius: 1rem;

        text-align: center;

        backface-visibility: hidden;
        box-shadow: var(--shadow-surface);

        &.flashcard__face--front {
            background: #10b981;
            color: #fff;
        }

        &.flashcard__face--back {
            transform: rotateY(180deg);

            border: 1px solid #10b981;
            background: #fff;

            .flashcard__counter {
                color: var(--color-muted);
                opacity: 1;
            }
        }
    }

    .flashcard__question {
        font-size: 1.5rem;
        font-weight: 600;
    }

    .flashcard__prompt {
        font-size: 0.875rem;
    }

    .flashcard__answer {
        font-size: 1.5rem;
        font-weight: 600;
    }

    .flashcard__counter {
        opacity: 0.9;
    }
}

.difficulty-list {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.difficulty {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;

    font-size: 0.875rem;
    font-weight: 500;

    .difficulty__icon {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 3.5rem;
        height: 3.5rem;
        border-radius: 999px;

        background: #fff;
        box-shadow: var(--shadow-surface);

        img {
            width: 2.25rem;
            height: 2.25rem;
        }
    }
}

/* ---------- Resumo ---------- */

.summary-card {
    border-radius: 1rem;
    padding: 1.25rem;

    font-size: 0.875rem;
    line-height: 1.6;

    background: #fff;
    box-shadow: var(--shadow-surface);

    @media (min-width: 48rem) {
        font-size: 1rem;
    }

    p + p {
        margin-top: 0.5rem;
    }

    .summary-card__equation {
        margin-block: 1rem;

        text-align: center;
        font-size: 1.125rem;
    }

    .summary-card__note {
        color: var(--color-muted);
    }
}

/* ---------- Simulado (alternativas) ---------- */

.quiz-question {
    font-weight: 600;
    text-wrap: pretty;
}

.alternatives {
    display: flex;
    flex-direction: column;

    margin-top: 1rem;
    gap: 0.5rem;
}

.alternative {
    display: flex;
    align-items: center;
    gap: 0.75rem;

    padding: 0.75rem 1rem;
    border-radius: 1rem;

    border: 2px solid transparent;
    background: #fff;

    cursor: pointer;
    transition:
        border-color 150ms cubic-bezier(0, 0, 0.2, 1),
        background-color 150ms cubic-bezier(0, 0, 0.2, 1);

    &:hover {
        border-color: #fdba74;
    }

    &:has(:focus-visible) {
        outline: 2px solid var(--color-accent);
        outline-offset: 2px;
    }

    &:has(:checked) {
        border-color: #ea580c;
        background: #fff7ed;

        .alternative__letter {
            background: #ea580c;
            color: #fff;
        }
    }

    .alternative__input {
        position: absolute;

        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;

        border: 0;

        white-space: nowrap;
        clip: rect(0, 0, 0, 0);
    }

    .alternative__letter {
        display: flex;
        flex-shrink: 0;
        align-items: center;
        justify-content: center;

        width: 2rem;
        height: 2rem;
        border-radius: 999px;

        background: #f4f4f5;

        font-weight: 600;

        transition:
            background-color 150ms cubic-bezier(0, 0, 0.2, 1),
            color 150ms cubic-bezier(0, 0, 0.2, 1);
    }

    .alternative__text {
        flex: 1;

        text-align: left;
    }
}

/* ---------- Progress: Ascensão ---------- */

.progress-card {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;

    border-radius: 1.5rem;
    padding: 1.25rem;

    background: #fff;
    box-shadow: var(--shadow-surface);

    @media (min-width: 48rem) {
        padding: 1.5rem;
    }

    .progress-card__header {
        display: flex;
        align-items: flex-start;
        gap: 1rem;

        > svg {
            width: 2.25rem;
            height: 2.25rem;

            color: var(--color-accent);
        }

        h3 {
            font-weight: 600;
        }

        p {
            margin-top: 0.25rem;

            font-size: 0.875rem;
            line-height: 1.6;
            color: var(--color-muted);
        }
    }

    .progress-card__icon {
        flex-shrink: 0;

        width: 2.25rem;
        height: 2.25rem;
    }
}

.week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;

    .week__day {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;

        min-width: 0;
    }

    .week__badge {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 100%;
        max-width: 2.5rem;
        aspect-ratio: 1;
        border-radius: 999px;

        @media (min-width: 48rem) {
            max-width: 3rem;
        }

        svg {
            width: 1rem;
            height: 1rem;

            @media (min-width: 40rem) {
                width: 1.25rem;
                height: 1.25rem;
            }
        }

        &.week__badge--done {
            background: var(--color-accent);
            color: var(--color-accent-foreground);
        }

        &.week__badge--today {
            border: 2px solid var(--color-accent);
            background: var(--color-accent-soft);
            color: var(--color-accent);
        }

        &.week__badge--future {
            background: #f4f4f5;
            color: #d4d4d8;
        }
    }

    .week__label {
        font-size: 0.75rem;
        color: var(--color-muted);
    }
}

/* ---------- Progress: Trilha (meter) ---------- */

.discipline-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.discipline {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    .discipline__row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .discipline__name {
        font-weight: 500;
    }

    .discipline__value {
        font-size: 0.875rem;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }
}

/* ---------- Tag (pilulas de rotulo) ---------- */

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;

    padding: 0.25rem 0.75rem;
    border-radius: 999px;

    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;

    background: var(--color-default);
    color: var(--color-muted);

    svg {
        width: 0.875rem;
        height: 0.875rem;
    }

    &.tag--accent {
        background: var(--color-accent-soft);
        color: var(--color-accent);
    }
}

/* ---------- Sessao: cronometro ---------- */

.timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;

    width: 100%;

    .timer__time {
        font-size: 3rem;
        font-weight: 800;
        line-height: 1.1;
        font-variant-numeric: tabular-nums;

        @media (min-width: 48rem) {
            font-size: 3.75rem;
        }
    }

    .timer__meter {
        width: 100%;
    }

    .timer__controls {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .timer__toggle {
        .timer__icon--pause {
            display: none;
        }

        &.is-running {
            .timer__icon--play {
                display: none;
            }

            .timer__icon--pause {
                display: block;
            }
        }
    }

    .timer__icon {
        width: 1rem;
        height: 1rem;
    }

    .timer__footer {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .timer__cycles {
        display: flex;
        align-items: center;
        gap: 0.375rem;
    }

    .timer__cycle {
        width: 0.5rem;
        height: 0.5rem;
        border-radius: 999px;

        background: var(--color-default);

        transition: background-color 300ms cubic-bezier(0, 0, 0.2, 1);

        &.timer__cycle--done {
            background: var(--color-accent);
        }
    }

    .timer__count {
        font-size: 0.875rem;
        font-variant-numeric: tabular-nums;

        color: var(--color-muted);
    }
}

/* ---------- Sessao: nota do Spotify ---------- */

.spotify-note {
    display: flex;
    align-items: center;
    gap: 0.75rem;

    padding: 1rem;
    border-radius: 1rem;

    font-size: 0.875rem;
    line-height: 1.6;

    background: #fff;
    box-shadow: var(--shadow-surface);

    img {
        flex-shrink: 0;

        width: 1.5rem;
        height: 1.5rem;
    }
}

.meter__track {
    position: relative;

    overflow: hidden;
    height: 0.5rem;
    border-radius: 2px;

    background: var(--color-default);

    .meter__fill {
        position: absolute;
        inset: 0;

        width: 100%;
        border-radius: 2px;

        transform: scaleX(var(--fill, 0));
        transform-origin: left;
        transition: transform 300ms cubic-bezier(0, 0, 0.2, 1);

        &.meter__fill--success {
            background: var(--color-success);
        }

        &.meter__fill--warning {
            background: var(--color-warning);
        }

        &.meter__fill--accent {
            background: var(--color-accent);
        }
    }
}

/* ---------- Final CTA ---------- */

.final-cta__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;

    border-radius: 1.5rem;
    padding: 3.5rem 1.5rem;

    text-align: center;

    background: #fff;
    box-shadow: var(--shadow-surface);

    @media (min-width: 48rem) {
        padding-block: 5rem;
    }

    h2 {
        max-width: 18ch;

        font-size: 1.875rem;
        letter-spacing: -0.01em;

        @media (min-width: 48rem) {
            font-size: 2.25rem;
        }
    }

    p {
        max-width: 52ch;

        line-height: 1.6;
        color: var(--color-muted);
    }
}

/* ---------- Team ---------- */

.team-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    gap: 1rem;

    border-radius: 1.5rem;
    padding: 1.25rem;

    text-align: center;

    background: #fff;
    box-shadow: var(--shadow-surface);
    outline-offset: 2px;

    transition: transform 200ms cubic-bezier(0, 0, 0.2, 1);

    @media (min-width: 48rem) {
        padding: 1.5rem;
    }

    @media (prefers-reduced-motion: no-preference) {
        &:hover {
            transform: translateY(-0.125rem);
        }
    }

    &:focus-visible {
        outline: 2px solid var(--color-accent);
    }

    p {
        margin-top: 0.25rem;

        font-size: 0.875rem;
        color: var(--color-muted);
    }
}

.avatar {
    display: block;
    flex-shrink: 0;
    overflow: hidden;

    border-radius: 999px;

    &.avatar--md {
        width: 5rem;
        height: 5rem;
    }

    .avatar__image {
        display: block;

        width: 100%;
        height: 100%;

        object-fit: cover;
    }
}
