/* ---------- Design tokens ---------- */
:root {
    --bg: #0e0e18;
    --surface: #1a1a2e;
    --surface-bar: #14142a;
    --surface-hover: #242442;
    --border: #2c2c4a;
    --accent: #ff4d6d;
    --accent-hover: #ff6b86;
    --accent-2: #ffb800;
    --text: #f5f5fa;
    --text-2: #9b9bb4;
    --success: #3ddc97;
    --danger: #ff6b6b;
    --poster-bg: #ffffff;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --page-width: 1100px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
}

h1, h2, h3 { margin: 0; font-weight: 400; line-height: 1.2; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h1:focus { outline: none; }
p { margin: 0; }

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

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

.muted { color: var(--text-2); }

/* ---------- Layout helpers ---------- */
.page-section {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

.page-header { margin-bottom: 1.5rem; display: grid; gap: .25rem; }

.centered-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.25rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font: inherit;
    cursor: pointer;
    text-decoration: none;

}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .45rem .8rem; font-size: .9rem; }

.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); border-color: var(--text-2); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--surface); border-color: var(--danger); color: var(--danger); }

/* ---------- Forms ---------- */
.field { display: grid; gap: .35rem; text-align: left; }
.field label { color: var(--text-2); font-size: .9rem; }

.input {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.input::placeholder { color: var(--text-2); }
.input:focus { outline: none; border-color: var(--accent); }
.input:read-only { color: var(--text-2); }

.notice {
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    font-size: .95rem;
    text-align: left;
}

.validation-message { color: var(--danger); font-size: .9rem; }

/* ---------- Cards and grids ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
}

.chip {
    display: inline-block;
    padding: .15rem .6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-2);
    font-size: .8rem;
    white-space: nowrap;
}
.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; }

.score { color: var(--accent-2); font-weight: 600; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

/* ---------- Blazor built-ins ---------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: .75rem 1.25rem;
    background: var(--danger);
    color: #1a0b0b;
}
#blazor-error-ui .reload { color: inherit; text-decoration: underline; margin-left: .5rem; }
#blazor-error-ui .dismiss { position: absolute; right: .75rem; top: .5rem; cursor: pointer; }

.blazor-error-boundary {
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--danger);
    color: #1a0b0b;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---------- Auth and account pages ---------- */
.auth {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 3rem 1rem;
    display: grid;
    gap: 1.5rem;
}

.auth h1 { text-align: center; }
.auth form { display: grid; gap: 1rem; }
.auth .switch { text-align: center; color: var(--text-2); font-size: .95rem; }

/* ---------- Status pages ---------- */
.status-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem 1rem;
    text-align: center;
}

.status-code { font-size: clamp(3rem, 12vw, 6rem); font-weight: 300; color: var(--accent); line-height: 1; }

/* ---------- Motion ---------- */
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to { opacity: 1; transform: none; }
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* "backwards" fill: no transform stays applied afterwards, so fixed backdrops inside keep working. */
.shell-content > * { animation: fade-in-up .3s ease backwards; }
.fade-in { animation: fade-in-up .35s ease backwards; }
.pop-in { animation: pop-in .15s ease backwards; transform-origin: top; }

.shimmer {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

.btn:active:not(:disabled) { transform: scale(.98); }
.btn { transition: background-color .15s, border-color .15s, color .15s, transform .1s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- Forms and loading ---------- */
.auth form { display: grid; gap: 1rem; }
.remember { display: flex; align-items: center; gap: .6rem; color: var(--text-2); font-size: .95rem; }
.remember input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
.field small { font-size: .85rem; }
.is-busy { opacity: .55; pointer-events: none; transition: opacity .2s; }

.page-section > .notice { margin-bottom: 1.25rem; }

.manual-link { margin-top: 2rem; text-align: center; }

.chip-adult { border-color: var(--accent); color: var(--accent); }

/* ---------- Spinner (a request is running) ---------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: none;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* Feedback that something is happening: it keeps turning, slowly, even for people who asked for less motion. */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2s !important;
        animation-iteration-count: infinite !important;
    }
}

/* A button that is waiting for the server stays readable: the spinner must be seen. */
.btn[aria-busy="true"]:disabled { opacity: .85; cursor: progress; }

/* ---------- Tabs for the type of title (anime, movies, series) ---------- */
.type-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .25rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.type-tabs .tab {
    padding: .3rem .9rem;
    border-radius: 999px;
    color: var(--text-2);
    font-size: .95rem;
    transition: background .15s, color .15s;
}
.type-tabs .tab:hover { background: var(--surface-hover); color: var(--text); }
.type-tabs .tab.active { background: var(--accent); color: var(--text); }


/* Out of sight until a keyboard user reaches it as the first stop of the page. */
.skip-link {
    position: absolute;
    left: .75rem;
    top: -4rem;
    z-index: 100;
    padding: .5rem .9rem;
    border-radius: var(--radius-sm, 8px);
    background: var(--accent);
    color: var(--on-accent, #fff);
    transition: top .15s;
}

.skip-link:focus { top: .75rem; }

main:focus { outline: none; }
