/* ============================================================
   Flashcards — CSS baseado na identidade visual do Starlight
   (blog.ferpdias.com.br). Sistema de cores em variáveis com
   dark/light toggle via [data-theme] no <html>.
   ============================================================ */

:root,
[data-theme="dark"] {
    --bg: #17181c;
    --bg-elevated: #23252c;
    --bg-nav: #0f1013;
    --text: #f7f8f8;
    --text-muted: #a0a2ac;
    --border: #2b2c30;
    --border-strong: #3d3f47;
    --accent: #a48ada;
    --accent-hover: #b9a4e5;
    --accent-soft: rgba(164, 138, 218, 0.15);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.5), 0 16px 48px rgba(0, 0, 0, 0.4);
    --code-bg: #1a1b20;
}

[data-theme="light"] {
    --bg: #ffffff;
    --bg-elevated: #f6f6f8;
    --bg-nav: #ffffff;
    --text: #1a1b1e;
    --text-muted: #545861;
    --border: #e6e7e9;
    --border-strong: #cccdd1;
    --accent: #6e42c1;
    --accent-hover: #542db3;
    --accent-soft: rgba(110, 66, 193, 0.12);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-strong: 0 4px 16px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.1);
    --code-bg: #f0f0f2;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    color-scheme: dark light;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

code, kbd {
    font-family: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
    font-size: 0.9em;
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--border);
}

kbd {
    display: inline-block;
    padding: 0.15em 0.5em;
    font-size: 0.8em;
    box-shadow: inset 0 -2px 0 var(--border-strong);
    min-width: 1.5em;
    text-align: center;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ============================================================
   Header
   ============================================================ */

.site-header {
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-weight: 600;
    font-size: 1.05rem;
    text-decoration: none;
}

.brand:hover {
    color: var(--accent);
    text-decoration: none;
}

.brand-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
    text-decoration: none;
}

.icon-btn .icon-sun { display: none; }
.icon-btn .icon-moon { display: block; }
[data-theme="light"] .icon-btn .icon-sun { display: block; }
[data-theme="light"] .icon-btn .icon-moon { display: none; }

/* ============================================================
   Main + Footer
   ============================================================ */

.site-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

.site-footer {
    background: var(--bg-nav);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ============================================================
   Home — hero + grid de decks
   ============================================================ */

.hero {
    text-align: center;
    padding: 2rem 0 3rem;
    max-width: 720px;
    margin: 0 auto;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-lead {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.deck-card {
    display: block;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.deck-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.deck-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}

.deck-card:hover::before {
    opacity: 1;
}

.deck-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 1rem;
}

.deck-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.deck-desc {
    font-size: 0.925rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.deck-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.deck-cat {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    text-transform: lowercase;
    font-weight: 500;
}

.deck-count {
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Deck page — breadcrumb, header, controles
   ============================================================ */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.breadcrumb .sep {
    opacity: 0.5;
}

.deck-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.deck-header-title {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.deck-header-icon {
    font-size: 2.75rem;
    line-height: 1;
}

.deck-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.deck-header-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.deck-header-stats {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    white-space: nowrap;
}

/* ============================================================
   Flashcard — flip 3D
   ============================================================ */

.study-area {
    max-width: 720px;
    margin: 0 auto;
}

.flashcard {
    perspective: 1500px;
    height: 380px;
    margin-bottom: 2rem;
    cursor: pointer;
    outline: none;
}

.flashcard:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 16px;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    inset: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.flashcard-front {
    border-top: 3px solid var(--accent);
}

.flashcard-back {
    transform: rotateY(180deg);
    border-top: 3px solid #4ade80;
}

.face-label {
    position: absolute;
    top: 1rem;
    left: 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}

.face-content {
    font-size: 1.35rem;
    line-height: 1.5;
    text-align: center;
    max-width: 100%;
    overflow-wrap: break-word;
    color: var(--text);
}

.face-content code {
    font-size: 0.95em;
}

.face-hint {
    position: absolute;
    bottom: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ============================================================
   Controls
   ============================================================ */

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    background: transparent;
    color: var(--text);
}

.btn:hover {
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
    min-width: 120px;
    justify-content: center;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-soft);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

.btn-ghost:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.secondary-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.keyboard-hints {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.keyboard-hints kbd {
    font-size: 0.7rem;
    margin: 0 0.15em;
}

/* ============================================================
   Empty state / 404
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    max-width: 480px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
    .header-inner {
        padding: 0.5rem 1rem;
    }

    .brand-name {
        display: none;
    }

    .site-main {
        padding: 1.5rem 1rem 3rem;
    }

    .deck-header {
        flex-direction: column;
        gap: 1rem;
    }

    .deck-header-stats {
        align-self: flex-start;
    }

    .flashcard {
        height: 320px;
    }

    .flashcard-face {
        padding: 2rem 1.25rem;
    }

    .face-content {
        font-size: 1.15rem;
    }

    .btn-primary {
        min-width: 100px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

