/*
Theme Name: oyasumi.baby
Theme URI: https://oyasumi.baby
Description: A minimal bedtime story theme designed for sleep. Features distraction-free reading with starry night backgrounds and wake lock support.
Version: 1.0.0
Author: oyasumi.baby
Author URI: https://oyasumi.baby
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: oyasumi-baby
*/

/* ========================================
   Reset & Base Styles
   ======================================== */

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

html {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body {
    min-height: 100%;
    background-color: #0a0e1a;
    color: #e8e4dc;
    font-family: 'BIZ UDPGothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    touch-action: pan-y;
    position: relative;
}

/* ========================================
   Fixed Background Layer
   ======================================== */

/* Works on all devices including mobile */
.ob-fixed-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('visual/bg2-optimized.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
}

/* ========================================
   Wake Lock Indicator
   ======================================== */

#ob-wake-indicator {
    position: fixed;
    top: 16px;
    right: 16px;
    font-size: 12px;
    opacity: 0;
    color: #c8c4bc;
    z-index: 9998;
    transition: opacity 0.3s;
}

#ob-wake-indicator.active {
    opacity: 0.5;
}

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

.ob-reader-mode {
    max-width: 500px;
    margin: 0 auto;
    padding: 60px 40px 0;
}

.ob-story-content {
    background: linear-gradient(to bottom,
        transparent 0%,
        transparent 20%,
        rgba(10, 14, 26, 0.6) 35%,
        rgba(10, 14, 26, 0.9) 85%,
        transparent 100%
    );
    margin: 0 -40px;
    padding: 0 40px 80px 40px;
}

@media (max-width: 640px) {
    html, body {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }

    .ob-reader-mode {
        padding: 40px 30px 0;
    }

    .ob-story-content {
        background: linear-gradient(to bottom,
            transparent 0%,
            transparent 20%,
            rgba(10, 14, 26, 0.6) 35%,
            rgba(10, 14, 26, 0.9) 85%,
            transparent 100%
        );
        margin: 0 -30px;
        padding: 0 30px 60px 30px;
    }

    .ob-custom-player {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

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

.ob-story-header {
    margin-bottom: 0;
    text-align: center;
    position: relative;
    padding-top: 40px;
}

.ob-logo-story {
    width: 165px;
    height: auto;
    opacity: 0.85;
    margin: 0 auto 2em;
    display: block;
    filter: brightness(0.92);
}

.ob-meta {
    display: block;
    font-size: 12px;
    color: #b8b4ac;
    margin-bottom: 1.5em;
    letter-spacing: 0.15em;
    font-weight: 400;
    opacity: 0.85;
}

.ob-story-header h1 {
    font-size: 28px;
    font-weight: 300;
    color: #e8e4dc;
    letter-spacing: 0.12em;
    line-height: 1.7;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* ========================================
   Divider
   ======================================== */

.ob-divider {
    text-align: center;
    margin: 0.8em 0 3em 0;
}

.ob-divider img {
    height: 10px !important;
    width: auto;
    opacity: 0.5;
}

/* ========================================
   Audio Player (Custom Design)
   ======================================== */

.ob-audio-player-wrapper {
    margin: 2em 0 3em 0;
}

.ob-audio-element {
    display: none;
}

.ob-audio-label {
    font-size: 12px;
    color: #b8b4ac;
    letter-spacing: 0.1em;
    margin-bottom: 1em;
    opacity: 0.7;
    text-align: center;
}

.ob-custom-player {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1em;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Volume Control (Most Important - Top Priority) */
.ob-volume-control {
    display: flex;
    align-items: center;
    gap: 0.6em;
    margin-bottom: 0.8em;
    padding: 0.7em;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.ob-volume-icon {
    font-size: 11px;
    color: #b8b4ac;
    letter-spacing: 0.1em;
    flex-shrink: 0;
    opacity: 0.8;
}

.ob-volume-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    outline: none;
}

.ob-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #e8e4dc;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.ob-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #e8e4dc;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.ob-volume-value {
    font-size: 12px;
    color: #e8e4dc;
    min-width: 35px;
    text-align: right;
    font-weight: 400;
}

/* Play Button */
.ob-play-button {
    width: 100%;
    padding: 0.7em;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e8e4dc;
    font-size: 14px;
    font-family: 'BIZ UDPGothic', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.7em;
}

.ob-play-button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

/* Progress Bar (Secondary) */
.ob-progress-container {
    opacity: 0.6;
}

.ob-progress-bar {
    width: 100%;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    outline: none;
    margin-bottom: 0.4em;
}

.ob-progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    background: #e8e4dc;
    border-radius: 50%;
    cursor: pointer;
}

.ob-progress-bar::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: #e8e4dc;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.ob-time-display {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #b8b4ac;
    opacity: 0.6;
}

/* ========================================
   Story Content
   ======================================== */

.ob-entry-content {
    font-size: 17px;
    line-height: 1.9;
    letter-spacing: 0.05em;
}

.ob-entry-content p {
    margin-bottom: 1.6em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* ========================================
   Story Footer
   ======================================== */

.ob-story-footer {
    margin-top: 10vh;
    background: transparent;
}

.ob-the-end {
    text-align: center;
    margin-top: 10vh;
    margin-bottom: 15vh;
    font-size: 1.5em;
    opacity: 0.5;
    font-weight: 300;
    letter-spacing: 0.3em;
}

.ob-back-button-container {
    text-align: center;
    margin-bottom: 15vh;
}

.ob-back-button {
    display: inline-block;
    padding: 0.5em 1.2em;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: #e8e4dc;
    font-size: 13px;
    text-decoration: none;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ob-back-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* ========================================
   SNS Share Buttons
   ======================================== */

.ob-share-container {
    text-align: center;
    margin-bottom: 8vh;
}

.ob-share-label {
    font-size: 11px;
    color: #b8b4ac;
    letter-spacing: 0.1em;
    margin-bottom: 1.2em;
    opacity: 0.6;
}

.ob-share-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8em;
    margin-bottom: 0.8em;
}

.ob-share-button {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #e8e4dc;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ob-share-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.ob-share-button:active {
    transform: translateY(0);
}

.ob-share-button svg {
    opacity: 0.85;
}

.ob-share-message {
    font-size: 11px;
    color: #e8e4dc;
    opacity: 0;
    transition: opacity 0.3s ease;
    min-height: 1.5em;
}

.ob-share-message.show {
    opacity: 0.7;
}

/* ========================================
   Favorite Button
   ======================================== */

.ob-favorite-button {
    position: absolute;
    top: -8px;
    right: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #e8e4dc;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ob-favorite-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.ob-favorite-button svg {
    opacity: 0.7;
    transition: all 0.3s ease;
}

.ob-favorite-button.favorited svg {
    fill: #f2b948;
    stroke: #f2b948;
    opacity: 1;
}

.ob-favorite-button.favorited {
    background: rgba(242, 185, 72, 0.15);
    border-color: rgba(242, 185, 72, 0.3);
}

/* Small favorite button for cards */
.ob-favorite-button-small {
    width: 32px;
    height: 32px;
    position: static;
}

.ob-favorite-button-small svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Ambient BGM Player
   ======================================== */

.ob-bgm-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
}

.ob-bgm-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e8e4dc;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ob-bgm-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.ob-bgm-toggle img {
    /* Icon is now part of vertical layout */
}

.ob-bgm-toggle.playing {
    background: rgba(147, 197, 253, 0.15);
    border-color: rgba(147, 197, 253, 0.3);
    animation: ob-pulse 2s ease-in-out infinite;
}

@keyframes ob-pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(147, 197, 253, 0.4);
    }
    50% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 8px rgba(147, 197, 253, 0);
    }
}

.ob-bgm-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: rgba(10, 14, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 1.2em;
    min-width: 200px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.ob-bgm-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ob-bgm-menu-title {
    font-size: 11px;
    color: #b8b4ac;
    letter-spacing: 0.12em;
    margin-bottom: 1em;
    opacity: 0.7;
    text-align: center;
}

.ob-bgm-sounds {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    margin-bottom: 0.8em;
}

.ob-bgm-sound-button {
    display: flex;
    align-items: center;
    gap: 0.8em;
    padding: 0.7em 1em;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e8e4dc;
    font-family: 'BIZ UDPGothic', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.ob-bgm-sound-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(2px);
}

.ob-bgm-sound-button.active {
    background: rgba(147, 197, 253, 0.15);
    border-color: rgba(147, 197, 253, 0.3);
}

.ob-bgm-sound-button.ob-bgm-off {
    border-color: rgba(255, 107, 107, 0.2);
}

.ob-bgm-sound-button.ob-bgm-off:hover {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.3);
}

.ob-bgm-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ob-bgm-icon img {
    width: 20px;
    height: 20px;
    opacity: 0.85;
}

.ob-bgm-name {
    flex: 1;
    letter-spacing: 0.05em;
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .ob-bgm-container {
        bottom: 16px;
        right: 16px;
    }

    .ob-bgm-toggle {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .ob-bgm-menu {
        right: 0;
        min-width: 180px;
    }
}

/* ========================================
   Scrollbar
   ======================================== */

::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

/* ========================================
   WordPress Core Overrides
   ======================================== */

/* Remove default WordPress styles that might interfere */
.ob-reader-mode .alignleft,
.ob-reader-mode .alignright,
.ob-reader-mode .aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.ob-reader-mode img {
    max-width: 100%;
    height: auto;
}
