/* ========================================
   SQUISHED - Book Viewer Styles
   Two Themes: Minimal (default), Playful
   ======================================== */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem 5rem 1rem;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Prevent double-tap zoom on iOS Safari */
.nav-btn,
.theme-btn,
.copy-btn,
.start-btn,
#siteBranding {
    touch-action: manipulation;
}

/* ========================================
   SITE HEADER
   ======================================== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.site-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.header-right {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-decoration: none;
    line-height: 1;
}

.site-subtitle {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-top: 0.4rem;
}

.site-link {
    font-size: 0.75rem;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.site-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.version-number {
    font-size: 0.6rem;
    opacity: 0.4;
    font-family: monospace;
}

/* ========================================
   THEME SWITCHER
   ======================================== */
.theme-switcher {
    display: flex;
    gap: 0.5rem;
}

/* ========================================
   START AGAIN BUTTON
   ======================================== */
.start-btn {
    padding: 0.5rem 0.7rem !important;
}

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

.theme-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.theme-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
}

.theme-btn.active {
    opacity: 1;
    transform: scale(1.05);
}

/* ========================================
   BOOK CONTAINER
   ======================================== */
.book-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    perspective: 1500px;
    position: relative;
    z-index: 50;
}

.book {
    width: 100%;
    position: relative;
    min-height: 70vh;
    max-height: 80vh;
    transition: all 0.5s ease;
    overflow: hidden;
}

/* ========================================
   PAGES
   ======================================== */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 70vh;
    display: none;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem 2rem;
    overflow-y: hidden;
    transition: all 0.4s ease;
}

.page.active {
    display: flex;
}

.page-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Title Page */
.title-page {
    justify-content: space-between;
    align-items: center;
    text-align: center;
    height: 100%;
}

.book-title {
    letter-spacing: 0.3em;
    margin-bottom: 0.5rem;
}

.title-divider {
    width: 100px;
    height: 2px;
    margin: 0.5rem 0;
}

.book-subtitle {
    letter-spacing: 0.15em;
    margin-bottom: 2rem;
}

.book-author {
    letter-spacing: 0.2em;
}

/* Shell image on title page */
.title-shell {
    max-width: 200px;
    max-height: 150px;
    width: auto;
    height: auto;
    margin: 1.5rem 0;
    object-fit: contain;
}

/* Story Pages */
.story-page {
    justify-content: flex-start;
    gap: 1.2rem;
}

.story-page p {
    text-align: justify;
    text-justify: inter-word;
}

/* Hidden elements for pagination */
.story-page p.hidden-overflow,
.ending-page p.hidden-overflow,
.author-note p.hidden-overflow,
.section-title.hidden-overflow,
.amazon-links.hidden-overflow {
    display: none;
}

.short-page {
    justify-content: center;
}

/* Continuation indicator */
.page-continuation {
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.6;
    padding-top: 1rem;
    font-style: italic;
}

.theme-playful .page-continuation {
    color: #2980b9;
    font-weight: 600;
}

/* Drop Cap */
.drop-cap::first-letter {
    float: left;
    font-size: 3.5em;
    line-height: 0.8;
    padding-right: 0.1em;
    margin-top: 0.05em;
}

/* Ending & Author Note Pages */
.ending-page,
.author-note {
    justify-content: center;
    gap: 1.5rem;
}

.section-title {
    text-align: center;
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
}

.author-signature {
    margin-top: 1.5rem;
    text-align: center;
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.7;
}

/* Quotes/Endorsements Page */
.quotes-page {
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
    padding: 1rem;
}

.endorsement-quote {
    text-align: center;
    max-width: 85%;
    margin: 0 auto;
}

.endorsement-quote p {
    font-size: 1.25rem;
    font-style: italic;
    line-height: 1.7;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.endorsement-quote cite {
    display: block;
    font-size: 0.95rem;
    font-style: normal;
    color: #666;
    margin-top: 0.5rem;
}

/* Theme-specific endorsement colors */
.theme-minimal .endorsement-quote p {
    color: #012A4A;
}

.theme-minimal .endorsement-quote cite {
    color: #D4A84B;
}

/* Page Numbers - hidden as they conflict with screen-based navigation */
.page-number {
    display: none;
}

/* ========================================
   NAVIGATION
   ======================================== */
.navigation {
    position: fixed;
    bottom: 4rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 3rem;
    z-index: 100;
    transition: all 0.3s ease;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.nav-arrow {
    font-size: 1.2rem;
}

.page-indicator {
    font-size: 0.9rem;
    min-width: 60px;
    text-align: center;
}

/* Swipe Hint */
.swipe-hint {
    position: fixed;
    bottom: 7.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.swipe-hint.visible {
    opacity: 0.8;
}

/* ========================================
   THEME: MINIMAL (Default)
   Clean, elegant, modern
   ======================================== */
.theme-minimal {
    background: #ffffff;
    color: #012A4A;
    font-family: 'Lora', Georgia, serif;
    position: relative;
}

.theme-minimal .theme-btn {
    background: #e0eef3;
    color: #012A4A;
}

.theme-minimal .theme-btn.active {
    background: #0086B6;
    color: white;
}

.theme-minimal .book {
    background: rgba(255,255,255,0.95);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,50,80,0.3);
    border: 2px solid #0086B6;
    position: relative;
    z-index: 50;
}

.theme-minimal .page {
    background: white;
}

.theme-minimal .book-title {
    font-size: 2.5rem;
    font-weight: 400;
    color: #012A4A;
}

.theme-minimal .title-divider {
    background: linear-gradient(90deg, #0086B6, #D4A84B);
}

.theme-minimal .book-subtitle {
    font-size: 0.9rem;
    color: #0086B6;
    font-weight: 400;
}

.theme-minimal .book-author {
    font-size: 1rem;
    color: #012A4A;
    font-weight: 400;
}

.theme-minimal .story-page p,
.theme-minimal .ending-page p,
.theme-minimal .author-note p {
    font-size: 1.3rem;
    line-height: 1.9;
    color: #012A4A;
}

.theme-minimal .drop-cap::first-letter {
    font-weight: 400;
    color: #0086B6;
}

.theme-minimal .section-title {
    font-size: 1.2rem;
    font-weight: 400;
    color: #012A4A;
}

.theme-minimal .page-continuation {
    color: #D4A84B;
    opacity: 0.7;
}

.theme-minimal .navigation {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    z-index: 100;
}

.theme-minimal .nav-btn {
    background: #e0eef3;
    color: #012A4A;
}

.theme-minimal .nav-btn:not(:disabled):hover {
    background: #0086B6;
    color: white;
}

.theme-minimal .swipe-hint {
    background: rgba(0,0,0,0.7);
    color: white;
}

.theme-minimal .site-header {
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.theme-minimal .site-title {
    color: #012A4A;
    font-family: 'Lora', Georgia, serif;
}

.theme-minimal .site-subtitle {
    color: #D4A84B;
    opacity: 1;
}

.theme-minimal .site-link {
    color: #567;
}

/* ========================================
   HIDE UNDERWATER ELEMENTS BY DEFAULT
   (Only visible in Playful theme)
   ======================================== */
.bubbles,
.sea-creatures,
.seaweed {
    display: none !important;
}

.theme-playful .bubbles,
.theme-playful .sea-creatures,
.theme-playful .seaweed {
    display: block !important;
}

/* ========================================
   THEME: PLAYFUL
   Underwater wonderland with sea creatures
   ======================================== */
.theme-playful {
    background: linear-gradient(180deg,
        #1a5276 0%,
        #2980b9 30%,
        #5dade2 60%,
        #85c1e9 80%,
        #a9dfbf 100%
    );
    color: #333;
    font-family: 'Nunito', sans-serif;
    overflow: hidden;
    position: relative;
}

/* Underwater light rays */
.theme-playful::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        repeating-linear-gradient(
            100deg,
            transparent,
            transparent 20px,
            rgba(255,255,255,0.03) 20px,
            rgba(255,255,255,0.03) 40px
        );
    animation: lightRays 20s linear infinite;
    pointer-events: none;
}

@keyframes lightRays {
    0% { transform: translateX(-10%) rotate(0deg); }
    100% { transform: translateX(10%) rotate(5deg); }
}

/* Bubbles container */
.theme-playful .bubbles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.theme-playful .bubble {
    position: absolute;
    bottom: -100px;
    background: radial-gradient(circle at 30% 30%,
        rgba(255,255,255,0.8),
        rgba(255,255,255,0.2) 50%,
        transparent 70%
    );
    border-radius: 50%;
    animation: bubbleRise linear infinite;
    opacity: 0.6;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-50vh) translateX(20px) scale(1.1);
        opacity: 0.4;
    }
    100% {
        transform: translateY(-110vh) translateX(-10px) scale(0.8);
        opacity: 0;
    }
}

/* Sea creatures container */
.theme-playful .sea-creatures {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.theme-playful .creature {
    position: absolute;
    opacity: 0.15;
    filter: blur(1px);
}

/* Fish swimming */
.theme-playful .fish {
    animation: fishSwim linear infinite;
}

@keyframes fishSwim {
    0% {
        transform: translateX(-100px) translateY(0) scaleX(-1);
    }
    49% {
        transform: translateX(calc(100vw + 100px)) translateY(30px) scaleX(-1);
    }
    50% {
        transform: translateX(calc(100vw + 100px)) translateY(30px) scaleX(1);
    }
    100% {
        transform: translateX(-100px) translateY(0) scaleX(1);
    }
}

/* Jellyfish floating */
.theme-playful .jellyfish {
    animation: jellyfishFloat ease-in-out infinite;
}

@keyframes jellyfishFloat {
    0%, 100% {
        transform: translateY(0) rotate(-5deg);
    }
    50% {
        transform: translateY(-30px) rotate(5deg);
    }
}

/* Starfish on bottom */
.theme-playful .starfish {
    bottom: 5%;
    animation: starfishSway ease-in-out infinite;
}

@keyframes starfishSway {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}

/* Seahorse bobbing */
.theme-playful .seahorse {
    animation: seahorseBob ease-in-out infinite;
}

@keyframes seahorseBob {
    0%, 100% {
        transform: translateY(0) rotate(-5deg);
    }
    50% {
        transform: translateY(-20px) rotate(5deg);
    }
}

/* Octopus pulsing */
.theme-playful .octopus {
    animation: octopusPulse ease-in-out infinite;
}

@keyframes octopusPulse {
    0%, 100% {
        transform: scale(1) translateY(0);
        opacity: 0.15;
    }
    50% {
        transform: scale(1.1) translateY(-15px);
        opacity: 0.2;
    }
}

/* Seaweed swaying */
.theme-playful .seaweed {
    position: fixed;
    bottom: 0;
    width: 30px;
    height: 150px;
    background: linear-gradient(to top, #1e8449, #27ae60, #2ecc71);
    border-radius: 50% 50% 0 0;
    transform-origin: bottom center;
    animation: seaweedSway ease-in-out infinite;
    opacity: 0.3;
    z-index: 1;
}

@keyframes seaweedSway {
    0%, 100% { transform: rotate(-10deg) scaleY(1); }
    50% { transform: rotate(10deg) scaleY(1.05); }
}

/* Sandy bottom gradient overlay */
.theme-playful::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to top,
        rgba(194, 178, 128, 0.4) 0%,
        rgba(194, 178, 128, 0.2) 50%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 1;
}

.theme-playful .theme-btn {
    background: rgba(255,255,255,0.3);
    color: white;
    position: relative;
    z-index: 100;
}

.theme-playful .theme-btn.active {
    background: white;
    color: #2980b9;
}

.theme-playful .book-container {
    position: relative;
    z-index: 10;
}

.theme-playful .book {
    background: linear-gradient(180deg, #fffef5 0%, #fff9e6 100%);
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(26, 82, 118, 0.4),
        0 0 0 8px rgba(255,255,255,0.3),
        inset 0 0 30px rgba(255,200,100,0.1);
    transform: rotate(-1deg);
    position: relative;
    z-index: 10;
}

.theme-playful .page {
    background: transparent;
}

.theme-playful .book-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: #1a5276;
    text-shadow: 3px 3px 0 #5dade2;
}

.theme-playful .title-divider {
    background: linear-gradient(90deg, #1a5276, #5dade2, #a9dfbf);
    height: 4px;
    border-radius: 2px;
}

.theme-playful .book-subtitle {
    font-size: 1.2rem;
    color: #2980b9;
    font-weight: 700;
}

.theme-playful .book-author {
    font-size: 1.3rem;
    color: #1a5276;
    font-weight: 700;
}

/* BIGGER TEXT FOR KIDS! */
.theme-playful .story-page p {
    font-size: 1.4rem;
    line-height: 2;
    color: #2c3e50;
}

.theme-playful .story-page {
    gap: 1.4rem;
}

.theme-playful .drop-cap::first-letter {
    font-weight: 800;
    color: #1a5276;
    text-shadow: 2px 2px 0 #5dade2;
    font-size: 4em;
}

.theme-playful .section-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1a5276;
}

.theme-playful .ending-page p,
.theme-playful .author-note p {
    font-size: 1.3rem;
    line-height: 1.9;
}

.theme-playful .navigation {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 8px 30px rgba(26, 82, 118, 0.3);
    border-radius: 3rem;
    position: relative;
    z-index: 100;
}

.theme-playful .nav-btn {
    background: linear-gradient(135deg, #2980b9, #1a5276);
    color: white;
    font-weight: 700;
}

.theme-playful .nav-btn:not(:disabled):hover {
    background: linear-gradient(135deg, #5dade2, #2980b9);
    box-shadow: 0 4px 15px rgba(41, 128, 185, 0.4);
}

.theme-playful .nav-btn:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
}

.theme-playful .page-indicator {
    color: #1a5276;
    font-weight: 700;
}

.theme-playful .page-number {
    color: #2980b9;
    font-weight: 700;
    font-size: 1rem;
}

.theme-playful .swipe-hint {
    background: linear-gradient(135deg, #2980b9, #1a5276);
    color: white;
    z-index: 100;
}

.theme-playful .site-header {
    background: rgba(26, 82, 118, 0.8);
}

.theme-playful .site-title {
    color: white;
    font-family: 'Nunito', sans-serif;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.theme-playful .site-subtitle {
    color: rgba(255,255,255,0.9);
}

.theme-playful .site-link {
    color: rgba(255,255,255,0.8);
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: 3.5rem 0 3rem 0;
    }

    .navigation {
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
        width: 100% !important;
        justify-content: center;
        padding: 0.4rem 1rem !important;
        gap: 0.8rem;
    }

    .site-header {
        padding: 0.5rem;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .site-subtitle {
        font-size: 0.6rem;
    }

    .site-link {
        font-size: 0.65rem;
    }

    .theme-switcher {
        gap: 0.25rem;
    }

    .theme-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }

    .book-container {
        max-width: 100%;
    }

    .book {
        min-height: 70vh;
        max-height: 75vh;
    }

    .page {
        padding: 1.5rem 1.25rem;
        min-height: 70vh;
    }

    .book-title {
        font-size: 2.5rem !important;
    }

    .book-author {
        font-size: 1.2rem !important;
    }

    .story-page p,
    .ending-page p,
    .author-note p {
        font-size: 1.2rem !important;
        line-height: 1.8 !important;
    }

    /* Keep playful text bigger on tablets */
    .theme-playful .story-page p,
    .theme-playful .ending-page p,
    .theme-playful .author-note p {
        font-size: 1.3rem !important;
        line-height: 1.9 !important;
    }

    .drop-cap::first-letter {
        font-size: 3em;
    }

    .nav-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .nav-text {
        display: none;
    }

    .swipe-hint {
        bottom: 7rem;
    }

    /* Remove book box on mobile — text IS the screen */
    .theme-minimal .book {
        border: none;
        box-shadow: none;
        border-radius: 0;
        background: #ffffff;
    }

    /* Hide some underwater elements on smaller screens */
    .theme-playful .seaweed:nth-child(n+4) {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        padding: 3rem 0 4.5rem 0;
    }

    .site-header {
        flex-direction: column;
        gap: 0.3rem;
        align-items: center;
    }

    .site-branding {
        align-items: center;
        text-align: center;
    }

    .header-right {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }

    .site-title {
        font-size: 1rem;
    }

    .page {
        padding: 1.25rem 1rem;
    }

    .book-title {
        font-size: 2.5rem !important;
        letter-spacing: 0.25em !important;
    }

    .book-author {
        font-size: 1.2rem !important;
    }

    .story-page p,
    .ending-page p,
    .author-note p {
        font-size: 0.95rem !important;
    }

    /* Keep playful text readable but slightly smaller on phones */
    .theme-playful .story-page p,
    .theme-playful .ending-page p,
    .theme-playful .author-note p {
        font-size: 1.15rem !important;
        line-height: 1.85 !important;
    }

    .theme-playful .book {
        transform: none;
        border-radius: 15px;
    }

    /* Simplify underwater on mobile for performance */
    .theme-playful .bubble:nth-child(n+10) {
        display: none;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes pageFlip {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
    }
    50% {
        transform: rotateY(-90deg);
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg);
        opacity: 1;
    }
}

.page.flipping {
    animation: pageFlip 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page.active .page-content {
    animation: fadeIn 0.4s ease-out;
}

/* Theme transition */
.book,
.page,
.navigation,
.theme-btn {
    transition: all 0.5s ease;
}

/* Hover effects for touch hint */
@media (hover: none) {
    .swipe-hint.visible {
        opacity: 0.9;
    }
}

/* ========================================
   COPY URL BUTTON
   ======================================== */
.copy-url-btn {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    background: rgba(0, 134, 182, 0.1);
    color: #0086B6;
    border: 1px solid rgba(0, 134, 182, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.copy-url-btn:hover {
    background: rgba(0, 134, 182, 0.2);
    border-color: #0086B6;
}

.copy-url-btn:active {
    transform: scale(0.95);
}

/* ========================================
   AMAZON LINKS
   ======================================== */
.amazon-links {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

.amazon-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.amazon-stores {
    font-size: 1rem;
}

.amazon-stores a {
    color: #0086B6;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s, opacity 0.3s;
}

.amazon-stores a:hover {
    color: #005580;
    text-decoration: underline;
}

/* Theme-specific Amazon link colors */
.theme-playful .amazon-stores a {
    color: #0086B6;
}

.theme-playful .amazon-stores a:hover {
    color: #00a8e6;
}

.theme-minimal .amazon-stores a {
    color: #555;
}

.theme-minimal .amazon-stores a:hover {
    color: #333;
}

/* ========================================
   SLIDE-UP SHARE TRAY
   ======================================== */
.share-tray {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 101;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tray-tab {
    cursor: pointer;
    padding: 0.6rem 1.8rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 1rem 1rem 0 0;
    background: rgba(255,255,255,0.95);
    color: #555;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    user-select: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.tray-tab:hover {
    color: #333;
}

.tray-arrow {
    font-size: 0.65rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.tray-content {
    background: rgba(255,255,255,0.97);
    padding: 0 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    width: 100%;
}

.tray-link-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    color: #555;
    font-size: 1rem;
}

.tray-link-row a {
    color: #0086B6;
    text-decoration: none;
    padding: 0.3rem 0;
}

.tray-link-row a:hover {
    text-decoration: underline;
}

.tray-link-row .copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.6;
    padding: 0.3rem;
    line-height: 1;
}

.tray-link-row .copy-btn:hover {
    opacity: 1;
}

/* When tray is open */
.share-tray.open .tray-content {
    max-height: 6rem;
    padding: 0.8rem 1.5rem;
}

.share-tray.open .tray-arrow {
    transform: rotate(180deg);
}

/* Theme-specific tray styling */
.theme-playful .tray-tab {
    background: rgba(255,255,255,0.95);
    color: #1a5276;
    box-shadow: 0 -2px 10px rgba(26, 82, 118, 0.15);
}

.theme-playful .tray-content {
    background: rgba(255,255,255,0.97);
    box-shadow: 0 -2px 10px rgba(26, 82, 118, 0.15);
}

.theme-playful .tray-link-row a {
    color: #1a5276;
}

/* Mobile tray adjustments */
@media (max-width: 768px) {
    .share-tray {
        width: 100%;
        bottom: 2.8rem;
    }

    .tray-tab {
        border-radius: 0;
        width: 100%;
        justify-content: center;
        padding: 0.7rem 1rem;
        font-size: 1rem;
    }

    .tray-link-row {
        font-size: 1.05rem;
    }
}

/* Mobile story text fine-tuning */
@media (max-width: 768px) {
    .story-page p,
    .ending-page p,
    .author-note p {
        font-size: 1.25rem !important;
        line-height: 1.85 !important;
    }
}

/* Print styles */
@media print {
    .theme-switcher,
    .navigation,
    .swipe-hint {
        display: none !important;
    }

    .page {
        page-break-after: always;
        display: block !important;
        position: relative !important;
    }
}
