/**
 * story.css - Estilos específicos para páginas de contos
 * Depende de: globals.css (deve ser importado primeiro)
 */

/* ================================================
   STORY LAYOUT
   ================================================ */
.story-page {
    min-height: 100vh;
}

.story-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 2rem 6rem;
    margin-top: 140px;
    opacity: 0;
    animation: fadeInUp 1s ease 0.6s forwards;
}

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

/* ================================================
   BACK BUTTON
   ================================================ */
.back-btn {
    display: inline-block;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
    cursor: pointer;
}

.back-btn:hover {
    color: var(--text-primary);
    transform: translateX(-5px);
}

/* ================================================
   STORY HEADER
   ================================================ */
.story-header {
    text-align: center;
    margin-bottom: 3rem;
}

.story-header h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.story-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-style: italic;
}

/* ================================================
   STORY CONTENT
   ================================================ */
.story-content {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    line-height: 2;
    text-align: justify;
}

.story-content p {
    margin-bottom: 1.5rem;
    text-indent: 2rem;
}

.story-content p:first-child {
    text-indent: 0;
}

/* Epígrafe - citação no início do conto */
.story-content .epigraph {
    font-style: italic;
    text-align: right;
    text-indent: 0;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    padding-left: 30%;
    font-size: 1.2rem;
    line-height: 1.8;
}

/* Drop cap no primeiro parágrafo real (ignora epígrafe) */
.story-content p:not(.epigraph):first-of-type::first-letter,
.story-content .epigraph + p::first-letter {
    font-size: 3.5rem;
    float: left;
    line-height: 1;
    margin-right: 0.5rem;
    margin-top: 0.1rem;
    color: var(--accent-red);
}

/* Desabilitar drop cap no modo bilíngue (quebra o layout de colunas) */
.story-bilingual .story-content p:not(.epigraph):first-of-type::first-letter,
.story-bilingual .story-content .epigraph + p::first-letter {
    font-size: inherit;
    float: none;
    line-height: inherit;
    margin-right: 0;
    margin-top: 0;
    color: inherit;
}

/* Parágrafo após epígrafe não tem indentação */
.story-content .epigraph + p {
    text-indent: 0;
}

/* ================================================
   RESPONSIVE - TABLET
   ================================================ */
@media (max-width: 768px) {
    .story-section {
        padding: 2rem 1.5rem 4rem;
    }

    .story-header h2 {
        font-size: 2rem;
    }

    .story-content {
        font-size: 1.1rem;
    }

    .story-content p:not(.epigraph):first-of-type::first-letter,
    .story-content .epigraph + p::first-letter {
        font-size: 3rem;
    }

    .story-content .epigraph {
        padding-left: 15%;
    }
}

/* ================================================
   SIDEBAR - NAVEGAÇÃO LATERAL (mesmo estilo do book.css)
   ================================================ */
.story-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1001;
    display: flex;
    align-items: stretch;
}

/* Linha vertical vermelha visível quando fechado */
.story-sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    background: linear-gradient(180deg,
        #5a0000 0%,
        #8B0000 15%,
        #a01010 50%,
        #8B0000 85%,
        #5a0000 100%);
    box-shadow: 2px 0 12px rgba(139, 0, 0, 0.6);
    transition: opacity 0.3s;
}

.story-sidebar.open::before {
    opacity: 0;
}

/* Botão toggle */
.story-sidebar .sidebar-toggle {
    position: relative;
    width: 32px;
    height: 100vh;
    background: linear-gradient(90deg, rgba(139, 0, 0, 0.4) 0%, rgba(139, 0, 0, 0.1) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.3s;
}

.story-sidebar .sidebar-toggle:hover {
    background: linear-gradient(90deg, rgba(160, 16, 16, 0.5) 0%, rgba(139, 0, 0, 0.2) 100%);
}

.story-sidebar .toggle-arrow {
    font-size: 1.6rem;
    color: #f0e6d3;
    font-weight: 400;
    transition: transform 0.3s;
    line-height: 1;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.story-sidebar .sidebar-toggle:hover .toggle-arrow {
    transform: scale(1.3);
    color: #fff;
}

/* Painel do sumário */
.story-sidebar .sidebar-panel {
    width: 0;
    height: 100vh;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    overflow: hidden;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.story-sidebar.open .sidebar-panel {
    width: 260px;
}

.story-sidebar .sidebar-header {
    padding: 80px 20px 15px;
    border-bottom: 1px solid var(--border);
}

.story-sidebar .sidebar-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.story-sidebar .sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 20px;
}

.story-sidebar .sidebar-author {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: #8B0000;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 12px 0 4px;
    margin-top: 12px;
    border-top: 1px solid rgba(139, 0, 0, 0.3);
}

.story-sidebar .sidebar-author:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.story-sidebar .sidebar-book {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.95rem;
    color: var(--accent-gold);
    font-weight: 500;
    padding: 8px 0 4px;
}

.story-sidebar .sidebar-link {
    display: block;
    padding: 6px 0;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.story-sidebar .sidebar-link:hover {
    color: var(--accent-red);
}

.story-sidebar .sidebar-link.active {
    color: #8B0000;
    font-weight: 500;
}

/* Compare buttons - mesmo estilo do book.css */
.story-sidebar .compare-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 10px;
}

.story-sidebar .compare-label {
    font-size: 0.85rem;
    color: #999;
    margin-right: 4px;
}

.story-sidebar .compare-btn {
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(139, 0, 0, 0.5);
    background: transparent;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.story-sidebar .compare-btn:hover {
    border-color: #8B0000;
    color: #fff;
    background: rgba(139, 0, 0, 0.2);
}

.story-sidebar .compare-btn.active {
    background: #8B0000;
    border-color: #8B0000;
    color: #fff;
    box-shadow: 0 0 8px rgba(139, 0, 0, 0.5);
}

/* ================================================
   TOOLTIPS DE DICA (compartilhado com book.css)
   ================================================ */
.tooltip-hint {
    position: fixed;
    background: linear-gradient(135deg, #8B0000 0%, #a01010 100%);
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 260px;
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.tooltip-hint.visible {
    opacity: 1;
    transform: translateX(0);
}

.tooltip-hint::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

/* Seta apontando para a esquerda (tooltip da sidebar) */
.tooltip-hint.arrow-left::before {
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #8B0000;
}

/* Seta apontando para cima (tooltip do compare) */
.tooltip-hint.arrow-up::before {
    top: -16px;
    left: 20px;
    border-bottom-color: #8B0000;
}

.tooltip-hint .close-tooltip {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
}

.tooltip-hint .close-tooltip:hover {
    color: #fff;
}

/* ================================================
   BILINGUAL VIEW - Parágrafos pareados
   ================================================ */
.story-paired-container {
    width: 100%;
}

.story-paired-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(139, 0, 0, 0.3);
}

.story-paired-label {
    font-size: 0.85rem;
    color: #8B0000;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.story-paired-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 1.5rem;
    align-items: start;
}

.story-paired-cell {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    line-height: 1.9;
    text-align: justify;
}

.story-paired-cell p {
    margin: 0;
    text-indent: 0;
}

.story-paired-cell:empty {
    /* Célula vazia para manter alinhamento */
    min-height: 1em;
}

/* Estilo antigo mantido para compatibilidade */
.story-bilingual {
    display: flex;
    gap: 40px;
    width: 100%;
}

.story-column {
    flex: 1;
    min-width: 0;
}

.story-lang-label {
    font-size: 0.85rem;
    color: #8B0000;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(139, 0, 0, 0.3);
}

/* ================================================
   RESPONSIVE - TABLET
   ================================================ */
@media (max-width: 768px) {
    .story-section {
        padding: 2rem 1.5rem 4rem;
    }

    .story-header h2 {
        font-size: 2rem;
    }

    .story-content {
        font-size: 1.1rem;
    }

    .story-content p:first-child::first-letter {
        font-size: 3rem;
    }

    .story-bilingual {
        flex-direction: column;
        gap: 2rem;
    }

    .story-column {
        padding-bottom: 2rem;
        border-bottom: 1px solid var(--border);
    }

    .story-column:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
}

/* ================================================
   RESPONSIVE - MOBILE
   ================================================ */
@media (max-width: 500px) {
    .story-section {
        margin-top: 160px;
    }

    .story-header h2 {
        font-size: 1.8rem;
    }

    .story-content {
        font-size: 1rem;
        text-align: left;
    }

    .story-sidebar.open .sidebar-panel {
        width: 200px;
    }
}

/* ================================================
   RESPONSIVE: Stack columns on small screens
   ================================================ */
@media (max-width: 900px) {
    .story-bilingual {
        flex-direction: column;
        gap: 50px;
    }

    .story-column {
        padding-bottom: 30px;
        border-bottom: 1px solid rgba(139, 0, 0, 0.2);
    }

    .story-column:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* Parágrafos pareados em telas menores */
    .story-paired-header,
    .story-paired-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .story-paired-row {
        padding-bottom: 1.5rem;
        margin-bottom: 1.5rem;
        border-bottom: 1px solid rgba(139, 0, 0, 0.15);
    }

    .story-paired-header {
        position: static;
        flex-direction: column;
    }

    .story-paired-cell {
        padding-left: 10px;
        border-left: 3px solid rgba(139, 0, 0, 0.3);
    }

    .story-paired-cell:first-child {
        border-left-color: #8B0000;
    }
}

@media (max-width: 768px) {
    .story-sidebar.open .sidebar-panel {
        width: 220px;
    }

    .story-sidebar .sidebar-header {
        padding: 70px 15px 12px;
    }
}
