/* Base CSS - Core styles and components shared across all pages */

/* ====== Global Reset ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* A modal dialog centres itself through the auto margins the reset above just
   zeroed. Restoring them here saves every dialog from doing it by hand. */
dialog {
    margin: auto;
}

/* ====== Body Base ====== */
body {
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #e3d5ff 0%, #ffd4e5 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* ====== Container ====== */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ====== Animations ====== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ====== Loading States ====== */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: 700;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 25px;
    border: 5px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ====== Error States ====== */
.error {
    text-align: center;
    padding: 60px 20px;
    background: var(--pastel-pink);
    border-radius: 12px;
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: 700;
    border: 3px solid var(--text-dark);
    box-shadow: 6px 6px 0 var(--text-dark);
}

/* ====== Selection Pills (Modifiers) ====== */
.selection-pill {
    display: inline-block;
    padding: 6px 14px;
    background: var(--pill-color, var(--pastel-blue));
    color: var(--pill-text, #fff);
    border: 2px solid var(--text-dark);
    border-radius: 20px;
    box-shadow: 3px 3px 0 var(--text-dark);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.selection-pill.pending {
    position: relative;
    border: 2px dashed var(--text-dark);
    background: var(--pill-color-light, rgba(147, 197, 253, 0.3));
    color: var(--text-dark);
    opacity: 0.85;
}

.selection-pill.removed {
    background: var(--pill-color-light, rgba(255, 200, 200, 0.3));
    border: 2px dashed #999;
    color: #666;
    text-decoration: line-through;
    opacity: 0.65;
}

/* ====== Vote Buttons ====== */
.voting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.vote-btn {
    background: white;
    border: 2px solid var(--text-dark);
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 2px 2px 0 var(--text-dark);
    color: var(--text-dark);
}

.vote-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--text-dark);
}

.vote-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.vote-btn.upvote.active {
    background: #b8e6b8;
    border-color: var(--text-dark);
    box-shadow: 3px 3px 0 var(--text-dark);
}

.vote-btn.downvote.active {
    background: #ffcab0;
    border-color: var(--text-dark);
    box-shadow: 3px 3px 0 var(--text-dark);
}

.vote-count {
    font-weight: 800;
    color: var(--text-dark);
    font-size: 16px;
    background: #d4b5f7;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid var(--text-dark);
    box-shadow: 2px 2px 0 var(--text-dark);
}

/* Page transition container */
.page-content {
    opacity: 1;
    transition: opacity 0.32s ease-in-out;
    will-change: opacity;
}

body.page-transition-init .page-content {
    opacity: 0;
}

body.page-transition-init.page-ready .page-content {
    opacity: 1;
}

body.page-transition-init.page-transitioning .page-content {
    opacity: 0;
}

/* ====== Character Cards ====== */
.character-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 6px 6px 0 var(--text-dark);
    transition: all 0.2s ease;
    cursor: pointer;
    border: 3px solid var(--text-dark);
    position: relative;
    overflow: hidden;
}

.character-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0 var(--text-dark);
}

.character-image {
    width: calc(100% + 50px);
    height: 400px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    margin: -25px -25px 20px -25px;
    border-bottom: 3px solid var(--text-dark);
}

/* ====== Toast Notifications ====== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1050;
    pointer-events: none;
}

.toast {
    background: #ffffff;
    border: 3px solid var(--text-dark);
    border-radius: 14px;
    box-shadow: 6px 6px 0 var(--text-dark);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 260px;
    max-width: 360px;
    color: var(--text-dark);
    pointer-events: auto;
    animation: toast-enter 0.22s ease-out both;
}

.toast.toast--error {
    background: #ffe5ec;
    border-color: #ec407a;
    box-shadow: 6px 6px 0 #c2185b;
}

.toast.toast--success {
    background: #e7f9ed;
    border-color: #2e7d32;
    box-shadow: 6px 6px 0 #1b5e20;
}

.toast.toast--info {
    background: #e5f0ff;
    border-color: #1e88e5;
    box-shadow: 6px 6px 0 #0d47a1;
}

.toast__icon {
    font-size: 1.4rem;
    line-height: 1;
    margin-top: 2px;
}

.toast__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast__message {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
}

.toast__details {
    font-size: 0.8rem;
    opacity: 0.8;
    line-height: 1.3;
}

.toast__close {
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: inherit;
    padding: 2px;
    margin-left: 6px;
}

.toast-leaving {
    animation: toast-exit 0.2s ease-in forwards;
}

.legendary-toast-container {
    z-index: 25000;
}

.legendary-toast {
    cursor: pointer;
}

.legendary-toast__open {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.legendary-toast__open:focus-visible {
    outline: 4px solid #b794f6;
    outline-offset: 4px;
}

/* ====== Global news ticker and notable card preview ====== */
.skip-link {
    position: fixed;
    z-index: 40000;
    top: 8px;
    left: 8px;
    padding: 12px 18px;
    border: 3px solid #2d2d2d;
    border-radius: 8px;
    background: #fffdf5;
    color: #2d2d2d;
    font-weight: 800;
    transform: translateY(calc(-100% - 16px));
}
.skip-link:focus { transform: none; outline: 3px solid #2d2d2d; outline-offset: 2px; }
#main-content { scroll-margin-top: 120px; }
#main-content:focus { outline: 3px solid #2d2d2d; outline-offset: -3px; }
.news-ticker__viewport:focus-visible { outline: 3px solid #2d2d2d; outline-offset: -3px; }
.motion-reduced .news-ticker__viewport,
.news-ticker:focus-within .news-ticker__viewport { overflow-x: auto; scrollbar-width: thin; }
.motion-reduced .news-ticker__track,
.news-ticker:focus-within .news-ticker__track { animation: none; transform: none; }
.motion-reduced .news-ticker [aria-hidden="true"],
.news-ticker:focus-within .news-ticker [aria-hidden="true"] { display: none; }
html.motion-reduced *, html.motion-reduced *::before, html.motion-reduced *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}
html.motion-reduced { scroll-behavior: auto !important; }
@media (max-width: 575px) { .news-ticker__label { display: none !important; } }
.news-ticker__edit { flex-shrink: 0; border: 0; border-right: 2px solid #2d2d2d; border-radius: 0; padding: 0 10px; background: #fff3bc; color: #2d2d2d; font: inherit; font-size: .75rem; cursor: pointer; }
.news-ticker-editor { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); margin: auto; box-sizing: border-box; padding: 24px; border: 3px solid #2d2d2d; border-radius: 16px; background: #fffdf5; color: #2d2d2d; box-shadow: 7px 7px 0 #2d2d2d; }
.news-ticker-editor::backdrop { background: rgb(0 0 0 / 55%); }
.news-ticker-editor h2 { margin-top: 0; }
.news-ticker-editor p { font-size: .9rem; line-height: 1.5; }
.news-ticker-editor textarea { display: block; box-sizing: border-box; width: 100%; margin-top: 8px; padding: 12px; resize: vertical; font: inherit; border: 2px solid #2d2d2d; border-radius: 8px; }
.news-ticker-editor footer { display: flex; justify-content: flex-end; gap: 12px; }
.news-ticker-editor footer button { padding: 10px 14px; border: 2px solid #2d2d2d; border-radius: 8px; background: white; color: #2d2d2d; font: inherit; font-weight: 700; cursor: pointer; }
.news-ticker-editor footer button[type="submit"] { background: #fff3bc; }
.news-ticker-editor button:disabled { opacity: .55; cursor: wait; }
.news-ticker-editor [role="status"] { min-height: 24px; margin: 8px 0; }
.news-ticker {
    position: fixed;
    z-index: 9999;
    top: 64px;
    left: 0;
    right: 0;
    height: 36px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border-bottom: 3px solid var(--text-dark, #2d2d2d);
    background: #fff3bc;
    color: var(--text-dark, #2d2d2d);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.news-ticker__label {
    z-index: 1;
    display: grid;
    place-items: center;
    padding: 0 12px;
    border-right: 3px solid var(--text-dark, #2d2d2d);
    background: #fe4a60;
    color: #202024;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.news-ticker__viewport {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.news-ticker__track {
    --news-ticker-gap: 32px;
    --news-ticker-half-gap: 16px;
    width: max-content;
    height: 100%;
    display: flex;
    align-items: center;
    gap: var(--news-ticker-gap);
    animation: news-ticker-scroll 38s linear infinite;
}

.news-ticker__sequence,
.news-ticker__cycle {
    flex: none;
    height: 100%;
    display: flex;
    align-items: center;
    gap: var(--news-ticker-gap);
}

.news-ticker__sequence {
    padding: 0 20px;
}

.news-ticker__track:hover,
.news-ticker__track:focus-within {
    animation-play-state: paused;
}

.news-ticker__track.is-empty {
    width: 100%;
    padding: 0 20px;
    animation: none;
}

.news-ticker__item,
.news-ticker__empty {
    flex: none;
    color: inherit;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.news-ticker__pull {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.news-ticker__pull:hover,
.news-ticker__pull:active {
    background: transparent;
    box-shadow: none;
    transform: none;
}

.news-ticker__pull.rarity-legendary { color: #9b5b00; }
.news-ticker__pull.rarity-unique { color: #6b28a8; }
.news-ticker__pull.rarity-mythical { color: #98162d; }
.news-ticker__pull.rarity-celestial { color: #4d43b3; }
.news-ticker__pull.rarity-gilded { color: #8a7300; }
.news-ticker__pull:focus-visible { outline: 3px solid #2d2d2d; outline-offset: 2px; }

body.has-news-ticker main {
    position: relative;
    top: 36px;
    margin-bottom: 36px;
}

body.has-news-ticker .main-interface {
    top: 100px;
    height: calc(100vh - 100px);
}

@keyframes news-ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(calc(-50% - var(--news-ticker-half-gap))); }
}

.notable-card-modal[hidden] { display: none; }

.notable-card-modal {
    position: fixed;
    z-index: 30000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(24, 20, 32, 0.76);
}

.notable-card-modal__panel {
    position: relative;
    width: min(440px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 34px 30px 24px;
    border: 3px solid var(--text-dark, #2d2d2d);
    border-radius: 16px;
    background: #fdf8ff;
    box-shadow: 10px 10px 0 #2d2d2d;
}

.notable-card-modal__panel:focus { outline: none; }

.notable-card-modal__close {
    position: absolute;
    z-index: 1;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 2px solid var(--text-dark, #2d2d2d);
    border-radius: 50%;
    background: #fff;
    color: inherit;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1;
}

.notable-card-modal__panel .trading-card { max-width: 100%; margin-inline: auto; }
.notable-card-modal__collector { margin: 22px 0 0; text-align: center; font-weight: 700; }
.notable-card-modal__collector a { color: #6b28a8; }
body.notable-card-modal-open { overflow: hidden; }

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-exit {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(12px) scale(0.9);
    }
}

.character-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #333;
    text-align: center;
}

.character-catchphrase {
    font-style: italic;
    color: var(--text-dark);
    margin-bottom: 15px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    padding: 10px 15px;
    background: #f4a6cd;
    border-radius: 8px;
    border: 2px solid var(--text-dark);
    box-shadow: 2px 2px 0 var(--text-dark);
}

.character-description {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.character-details {
    font-size: 13px;
    color: var(--text-dark);
    margin-bottom: 20px;
    padding: 12px;
    background: #f5d982;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    border: 2px solid var(--text-dark);
    box-shadow: 2px 2px 0 var(--text-dark);
}

.no-image {
    width: calc(100% + 50px);
    height: 400px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    margin: -25px -25px 20px -25px;
    font-size: 2rem;
    border-bottom: 3px solid var(--text-dark);
}

/* ====== Modal Base Styles ====== */
.modal, .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active, .modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border: 3px solid var(--text-dark);
    box-shadow: 8px 8px 0 var(--text-dark);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f4a6cd;
    border: 2px solid var(--text-dark);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 var(--text-dark);
    transition: all 0.2s ease;
}

.modal-close:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--text-dark);
}

.modal-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 15px;
    text-align: center;
}

.modal-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid var(--text-dark);
    box-shadow: 3px 3px 0 var(--text-dark);
    margin-bottom: 20px;
}

.modal-catchphrase {
    font-style: italic;
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding: 12px 20px;
    background: #f4a6cd;
    border-radius: 8px;
    border: 2px solid var(--text-dark);
    box-shadow: 2px 2px 0 var(--text-dark);
}

.modal-description {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}

.modal-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

/* ====== Camera Capture Overlay ====== */
body.camera-capture-open {
    overflow: hidden;
}

.camera-capture-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(32, 28, 56, 0.72);
    z-index: 11000;
}

.camera-capture-overlay[hidden] {
    display: none !important;
}

.camera-capture-modal {
    width: min(520px, 100%);
    background: var(--bg-subtle);
    border: 3px solid var(--text-dark);
    border-radius: 18px;
    box-shadow: 10px 10px 0 var(--text-dark);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: fadeIn 0.25s ease-out;
    position: relative;
}

.camera-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.camera-modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-dark);
}

.camera-close-btn {
    background: var(--pastel-pink);
    border: 2px solid var(--text-dark);
    border-radius: 10px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--text-dark);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.camera-close-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--text-dark);
}

.camera-video-wrapper {
    position: relative;
    border: 2px dashed var(--text-dark);
    border-radius: 16px;
    background: var(--bg-cream);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
}

.camera-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-permission-tip {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background: rgba(255, 255, 255, 0.82);
    border: 2px solid var(--text-dark);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-dark);
    box-shadow: 3px 3px 0 var(--text-dark);
}

.camera-modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.camera-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 2px solid var(--text-dark);
    border-radius: 12px;
    background: var(--muted-gray);
    color: var(--text-dark);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--text-dark);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.camera-action-btn i {
    font-size: 1.1rem;
}

.camera-action-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--text-dark);
}

.camera-action-primary {
    background: var(--pastel-blue);
}

@media (max-width: 540px) {
    .camera-capture-modal {
        padding: 18px;
        box-shadow: 6px 6px 0 var(--text-dark);
    }

    .camera-modal-actions {
        justify-content: center;
    }

    .camera-action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ====== Placeholder States ====== */
.placeholder {
    text-align: center;
    color: #999;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.placeholder p {
    font-size: 1rem;
    margin: 0;
}

/* ====== Responsive Breakpoints ====== */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        padding: 0 10px;
    }

    .character-card {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }
}
@media (max-width: 999px) {
    .news-ticker { top: 60px; }

    body.has-news-ticker .main-interface,
    body.has-news-ticker .main-interface.is-mobile {
        top: 96px;
        height: calc(100dvh - 96px);
        min-height: calc(100vh - 96px);
    }
}
