/* World Preview Page Styles */

/* =========================================================================
   Container
   ========================================================================= */

.preview-container {
    max-width: 860px;
    margin: 0 auto;
    padding-bottom: 60px;
}

/* =========================================================================
   Loading / Error states
   ========================================================================= */

.loading-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-dim);
    font-size: 0.8rem;
    letter-spacing: 2px;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.2s steps(4, end) infinite;
}

@keyframes loadingDots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
}

.error-state {
    text-align: center;
    padding: 80px 24px;
    color: #f44336;
    font-size: 0.85rem;
}

/* =========================================================================
   Hero
   ========================================================================= */

.preview-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 2.2 / 1;
    background: #111;
    overflow: hidden;
}

.preview-hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.65) brightness(0.75);
}

.preview-hero-placeholder {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        #111 0px, #111 20px,
        #141414 20px, #141414 40px
    );
}

/* Scanline overlay */
.preview-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent, transparent 2px,
        rgba(0, 0, 0, 0.08) 2px, rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    z-index: 1;
}

/* Gradient fade to body background */
.preview-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65%;
    background: linear-gradient(transparent, #0a0a0a);
    pointer-events: none;
    z-index: 2;
}

.hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 32px;
    z-index: 3;
}

.hero-code {
    color: var(--text-dim);
    font-size: 0.6rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.world-title {
    font-size: 2rem;
    font-weight: bold;
    color: #FFBF00;
    margin: 0 0 8px 0;
    line-height: 1.1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.world-meta {
    color: var(--text-dim);
    font-size: 0.7rem;
    letter-spacing: 1.5px;
}

/* =========================================================================
   Lineage
   ========================================================================= */

.world-lineage {
    padding: 8px 32px;
    color: var(--text-dim);
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.world-lineage a {
    color: #FFBF00;
    text-decoration: none;
}

.world-lineage a:hover {
    text-decoration: underline;
}

/* =========================================================================
   Like button
   ========================================================================= */

.like-section {
    margin-bottom: 28px;
}

.like-btn {
    background: transparent;
    border: 1px solid #333;
    color: var(--text-dim);
    padding: 8px 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s, color 0.2s;
}

.like-btn:hover {
    border-color: #FFBF00;
    color: #FFBF00;
}

.like-btn:focus-visible {
    outline: 2px solid #FFBF00;
    outline-offset: 2px;
}

.like-btn.liked {
    border-color: #FFBF00;
    color: #FFBF00;
}

.like-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.like-count {
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* =========================================================================
   Body
   ========================================================================= */

.preview-body {
    padding: 32px;
}

.world-description {
    color: #ccc;
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 32px 0;
    max-width: 680px;
}

/* =========================================================================
   Section divider
   ========================================================================= */

.section-divider {
    color: var(--text-dim);
    font-size: 0.6rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* =========================================================================
   Entity tags
   ========================================================================= */

.entity-tags {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
}

.entity-type-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.entity-type-label {
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
    min-width: 80px;
}

.entity-tag {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    padding: 4px 10px;
    font-size: 0.7rem;
    color: #ccc;
    letter-spacing: 0.5px;
}

.entity-tag-more {
    padding: 4px 10px;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

/* =========================================================================
   Premade characters
   ========================================================================= */

#premade-section {
    margin-bottom: 32px;
}

.char-scroll {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.char-card {
    flex: 1 1 180px;
    max-width: 280px;
    cursor: pointer;
    border: 1px solid #222;
    background: #111;
    transition: border-color 0.2s;
    position: relative;
}

.char-card:hover {
    border-color: #555;
}

.char-card.selected {
    border-color: #FFBF00;
    box-shadow: 0 0 12px rgba(255, 191, 0, 0.2);
}

.char-card.selected::before,
.char-card.selected::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    z-index: 2;
}

.char-card.selected::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid #FFBF00;
    border-left: 2px solid #FFBF00;
}

.char-card.selected::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid #FFBF00;
    border-right: 2px solid #FFBF00;
}

/* Square portrait */
.char-portrait {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #1a1a1a;
    overflow: hidden;
}

.char-portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.7) brightness(0.85);
}

.char-portrait-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: #333;
    font-size: 1.8rem;
}

.char-info {
    padding: 8px 10px;
}

.char-name {
    color: #e0e0e0;
    font-size: 0.7rem;
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-class {
    color: var(--text-dim);
    font-size: 0.6rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================================
   Actions
   ========================================================================= */

.action-row {
    display: flex;
    flex-direction: column;
    margin-top: 32px;
}

.action-block {
    padding: 24px;
    border: 1px solid #222;
    background: #111;
    position: relative;
}

.action-block + .action-block {
    border-top: none;
}

/* L-bracket corners */
.action-block::before,
.action-block::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    z-index: 1;
}

.action-block:first-child::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid #FFBF00;
    border-left: 2px solid #FFBF00;
}

.action-block:last-child::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid #FFBF00;
    border-right: 2px solid #FFBF00;
}

.action-block-label {
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.action-block-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 16px;
    line-height: 1.4;
}

.action-block-cost {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 10px;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #FFBF00;
    color: #0a0a0a;
    border: none;
    padding: 14px 28px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: #ffd040;
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn-secondary {
    background: transparent;
    color: #FFBF00;
    border: 1px solid #FFBF00;
    padding: 14px 28px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 191, 0, 0.08);
}

.btn-secondary:active:not(:disabled) {
    background: rgba(255, 191, 0, 0.15);
}

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

.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline: 2px solid #FFBF00;
    outline-offset: 2px;
}

.action-footer {
    text-align: center;
    padding: 12px 0 0;
    color: var(--text-dim);
    font-size: 0.6rem;
    letter-spacing: 1px;
}

/* =========================================================================
   Mobile
   ========================================================================= */

@media (max-width: 768px) {
    .preview-hero {
        aspect-ratio: 3 / 2;
    }

    .world-title {
        font-size: 1.4rem;
    }

    .hero-overlay {
        padding: 16px 20px;
    }

    .world-lineage {
        padding: 8px 16px;
    }

    .like-btn {
        min-height: 44px;
    }

    .preview-body {
        padding: 20px 16px;
    }

    .char-scroll {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 8px;
        scrollbar-width: thin;
        scrollbar-color: #333 transparent;
    }

    .char-scroll::-webkit-scrollbar {
        height: 4px;
    }

    .char-scroll::-webkit-scrollbar-track {
        background: transparent;
    }

    .char-scroll::-webkit-scrollbar-thumb {
        background: #333;
    }

    .char-card {
        flex: 0 0 120px;
        max-width: none;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 44px;
    }

    .action-block {
        padding: 20px 16px;
    }
}
