/* ==========
   LIGHT SONIC-INSPIRED THEME
   Bright blues, sky gradients, gold ring accents
   ========== */

:root {
    --sky-top: #c9e8ff;
    --sky-mid: #a9d8ff;
    --sky-bottom: #6fb8ff;
    --panel-bg: rgba(255, 255, 255, 0.78);
    --panel-border: rgba(0, 90, 180, 0.25);
    --accent-blue: #0078ff;
    --accent-blue-glow: rgba(0, 120, 255, 0.4);
    --accent-gold: #ffcd38;
    --accent-gold-shadow: 0 0 10px rgba(255, 205, 56, 0.65);
    --text-dark: #0a1c33;
    --text-muted: #486b96;
}

/* Layout */

html,
body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 90vh;
    font-family: system-ui, sans-serif;
    background: linear-gradient(to bottom, var(--sky-top), var(--sky-mid), var(--sky-bottom));
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.5rem;
}

/* RP pages: full-height layout, no outer scroll */

body.rp-page {
    margin: 0;
    height: 100vh;          /* lock to viewport height */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 1rem;
    overflow: hidden;       /* no outer scroll */
}

.page-shell {
    width: 100%;
    max-width: 900px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 1.25rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 0 18px rgba(0, 60, 130, 0.25);
}

body.rp-page .page-shell {
    width: 100%;
    max-width: 960px;        /* nice width on desktop */
    height: 86%;
    max-height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Header */

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-shadow: 0 0 6px var(--accent-blue-glow);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: rgba(0, 120, 255, 0.1);
    border: 1px solid rgba(0, 120, 255, 0.25);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--accent-blue);
}

.badge-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--accent-gold);
    box-shadow: var(--accent-gold-shadow);
}

/* Lock Screen */

#lock-screen {
    margin-top: 1rem;
    padding: 1.25rem;
    background: #ffffffd9;
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
}

.lock-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.lock-ring {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    border: 4px solid var(--accent-gold);
    box-shadow: var(--accent-gold-shadow);
}

.lock-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
}

.lock-text {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
}

.lock-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
}

input[type="password"] {
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(0,0,0,0.2);
    background: white;
    font-size: 0.92rem;
}

input[type="password"]:focus {
    outline: 2px solid var(--accent-blue);
}

.button-ring {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    background: var(--accent-gold);
    border: none;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--accent-gold-shadow);
    transition: transform 0.08s ease;
}

.button-ring:hover {
    transform: translateY(-1px);
}

.lock-error {
    color: red;
    font-size: 0.85rem;
}

/* RP Content */

#rp-shell {
    display: none;          /* JS flips this to flex on unlock */
    flex-direction: column;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;          /* IMPORTANT: enables child scrolling inside flex */
}

/* Old .rp-controls kept for safety even though top-controls is now used */
.rp-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: stretch;
}

#rp-page-container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-y: auto;       /* scroll here */
    padding: 1rem;
    border-radius: 0.8rem;
    background: #ffffffec;
    border: 1px solid var(--panel-border);
    box-sizing: border-box;
}

.rp-page-content {
    white-space: pre-wrap;
    line-height: 1.5;
    color: var(--text-dark);
}

.rp-page-content strong,
.rp-page-content b {
    color: var(--accent-blue);
}

.rp-page-content em,
.rp-page-content i {
    color: #c04aff;
}

/* Divider between posts */

.rp-divider {
    text-align: center;
    margin: 0rem 0;
    line-height: 1;
}

/* Pagination */

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pagination-ring {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    border: none;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-blue-glow);
    transition: transform 0.08s ease, opacity 0.08s ease;
}

.pagination-ring[disabled] {
    opacity: 0.4;
    cursor: default;
}

.pagination-ring:not([disabled]):hover {
    transform: translateY(-1px);
}

.page-indicator {
    font-size: 0.86rem;
    color: var(--text-muted);
}

.story-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========
   TOP CONTROLS BAR
   (pagination • TTS • search)
   ========== */

.top-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    margin-bottom: 0.75rem;
}

/* Left / center / right groups */

.left-group,
.right-group {
    flex: 0 0 auto;
}

.center-group {
    flex: 1;
    display: flex;
    justify-content: center;   /* keeps TTS centered between left/right */
}

/* ==========
   TTS PLAYER CONTROLS
   ========== */

.tts-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    justify-content: center;
    font-size: 0.85rem;
}

.tts-btn {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 0 6px var(--accent-blue-glow);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tts-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 10px var(--accent-blue-glow);
}

.tts-mode {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.2);
    font-size: 0.8rem;
    background: #ffffffcc;
}

/* ==========
   SEARCH BAR
   ========== */

.search-bar {
    display: flex;
    flex-wrap: nowrap;          /* keep input + buttons on one line on wide screens */
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 260px;            /* take remaining space on the right */
    justify-content: flex-end;
    font-size: 0.9rem;
}

.search-input {
    flex: 1 1 200px;
    max-width: 320px;
    min-width: 160px;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(0,0,0,0.2);
    background: #ffffff;
}

.search-input:focus {
    outline: 2px solid var(--accent-blue);
}

.search-main-btn,
.search-clear-btn,
.search-nav-btn {
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.search-main-btn {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 6px var(--accent-blue-glow);
}

.search-clear-btn {
    background: #e0e3ef;
    color: var(--text-dark);
}

.search-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.5rem;
}

.search-nav-btn {
    background: #e0e7ff;
    color: var(--text-dark);
}

.search-status {
    flex-basis: 100%;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

.search-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* highlight style */
mark.search-hit {
    background: #fff59d;
    padding: 0 2px;
    border-radius: 2px;
}

/* =============================================
   GOLD RING HUB BUTTON (Sonic-style portal)
   ============================================= */

.hub-ring {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        transparent 45%,   /* hollow center */
        gold 55%,
        #f6c200 70%,
        #d49a00 100%
    );
    color: #333;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    line-height: 70px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 8px rgba(255, 223, 102, 0.8),
        0 0 14px rgba(255, 200, 60, 0.5),
        inset 0 0 6px rgba(255, 255, 255, 0.6),
        inset 0 0 12px rgba(255, 150, 0, 0.6);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

/* Text inside the ring */
.hub-ring span {
    font-size: 0.9rem;
    font-weight: 700;
    color: #0048a8; /* Sonic blue */
    text-shadow: 0 0 4px white;
}

/* Hover animation: ring spins upward */
.hub-ring:hover {
    transform: translateY(-3px) rotate(10deg) scale(1.15);
    box-shadow:
        0 0 12px rgba(255, 230, 120, 1),
        0 0 20px rgba(255, 200, 60, 0.8),
        inset 0 0 6px rgba(255, 255, 255, 0.8);
}

/* Click squash for feedback */
.hub-ring:active {
    transform: scale(0.92);
}

/* =============================================
   RESPONSIVE TWEAKS
   ============================================= */

/* Medium screens – stack header a bit nicer */
@media (max-width: 900px) {
    header {
        align-items: flex-start;
    }

    .title {
        font-size: 1.55rem;
    }

    .top-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .left-group,
    .center-group,
    .right-group {
        justify-content: center;
    }

    .search-bar {
        flex-wrap: wrap;          /* allow wrapping on narrow screens */
        justify-content: center;
    }

    #rp-page-container {
        padding: 0.75rem;
    }
}

/* Small screens – shrink title + hub ring further */
@media (max-width: 600px) {
    body.rp-page {
        padding: 0.6rem;
    }

    .page-shell {
        padding: 0.9rem;
		height: 50%;
    }

    .title {
        font-size: 1.35rem;
        text-align: center;
    }

    .subtitle {
        text-align: center;
    }

    .hub-ring {
        width: 52px;
        height: 52px;
        line-height: 52px;
        font-size: 0.75rem;
        top: 0.6rem;
        right: 0.5rem;
    }
	
	.search-bar {
        flex-wrap: nowrap;        
        justify-content: center;
    }
	.tts-controls {
		flex-wrap: nowrap;        
        justify-content: center;
	}
	.pagination-controls{
		flex-wrap: nowrap;        
        justify-content: center;
	}
}
