/*
=======================================
THE STORY SO FAR — the chronicle, read end to end
story.css
=======================================

The long form of the hub's Chronicle section: act and chapter dividers,
then one card per session. Shape and colour follow BRANDING.md — square,
gold hairlines for structure, crimson for the current thing, parchment
for speech. Every colour here is a token from crimson-court.css.
*/

.story-page { overflow-x: hidden; }

/*
Story controls
*/
.story-controls {
    position: relative;
    /* Above the chronicle below it. Every .container is a positioned box at
       z-index 1 (styles.css), so the story section's container, later in
       the document, painted over an open dropdown: the act and chapter
       dividers showed through the menu and took its clicks. Making the
       controls their own stacking context, one above, keeps the menus
       (z-index 10 inside it) over the content. */
    z-index: 2;
    margin-bottom: 30px;
    padding: 16px 18px;
    background: var(--court-raised);
    border: 1px solid var(--court-line);
}

.story-controls .container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px 18px;
    max-width: 100%;
    padding: 0;
}

/* Dropdowns */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-button {
    min-width: 180px;
    padding: 10px 14px;
    background: var(--court-surface);
    border: 1px solid var(--court-border);
    border-radius: 2px;
    color: var(--parchment);
    font-family: 'Cinzel', Georgia, serif;
    font-size: 12px;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: background .18s ease, border-color .18s ease;
}

.dropdown-button:hover {
    background: var(--court-hover);
    border-color: var(--royal-gold);
}

.dropdown-button i.fa-chevron-down {
    color: var(--royal-gold);
    transition: transform .18s ease;
}

.dropdown-button.active i.fa-chevron-down { transform: rotate(180deg); }

.dropdown-content {
    display: none;
    position: absolute;
    min-width: 250px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--court-raised);
    border: 1px solid var(--court-border);
    border-radius: 0;
    box-shadow: 0 8px 30px #0006;
    z-index: 10;
}

.dropdown-content.show {
    display: block;
    animation: fadeDropdown .2s ease forwards;
}

.dropdown-item {
    display: block;
    padding: 10px 14px;
    color: var(--parchment);
    text-decoration: none;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 17px;
    border-bottom: 1px solid var(--court-line);
    transition: background .18s ease, color .18s ease;
}

.dropdown-item:last-child { border-bottom: none; }

.dropdown-item:hover {
    background: var(--court-hover);
    color: var(--royal-gold-light);
}

.dropdown-item.active {
    background: var(--crimson-dark);
    color: var(--parchment);
}

@keyframes fadeDropdown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.act-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Search */
.story-search {
    display: flex;
    position: relative;
    margin-left: auto;
}

.story-search input {
    width: 230px;
    height: 40px;
    padding: 10px 40px 10px 12px;
    background: var(--court-surface);
    border: 1px solid var(--court-border);
    border-radius: 2px;
    color: var(--parchment);
    font: 17px 'EB Garamond', Georgia, serif;
    transition: border-color .18s ease;
}

.story-search input:focus {
    border-color: var(--royal-gold);
    outline: none;
}

.story-search input::placeholder { color: var(--court-secondary); }

.story-search button {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 38px;
    background: transparent;
    border: none;
    color: var(--royal-gold);
    cursor: pointer;
}

/*
Main story structure
*/
.story-section {
    position: relative;
    padding: 0;
    overflow: visible !important;
}

.story-section .container {
    max-width: 100%;
    padding: 0;
}

.story-content {
    position: relative;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

/*
Act / chapter dividers.
A rule across the page with the act's name set into it — the same band the
hub uses to separate acts in its chronicle grid.
*/
.story-divider {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    margin: 18px 0 0;
    text-align: left;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .5s ease-out, transform .5s ease-out;
}

.story-divider.visible {
    opacity: 1;
    transform: translateY(0);
}

.story-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--court-border), transparent);
}

.divider-content {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: var(--parchment);
}

/* The gold diamond that heads every section in the court. */
.divider-content::before {
    content: '';
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    background: var(--royal-gold);
    transform: rotate(45deg);
}

.divider-content i { display: none; }

.divider-text { text-align: left; }

.divider-title {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 15px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--royal-gold);
    margin: 0;
    text-shadow: none;
}

.divider-subtitle {
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 17px;
    color: var(--court-secondary);
    margin: 4px 0 0;
}

.story-divider[data-type="chapter"] { margin-top: 10px; }

.story-divider[data-type="chapter"] .divider-title {
    font-size: 13px;
    letter-spacing: .16em;
    color: var(--crimson-light);
}

/*
Story episode
*/
.story-episode {
    position: relative;
    background: var(--court-raised);
    border: 1px solid var(--court-border);
    border-left: 2px solid var(--court-border);
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .5s ease-out, transform .5s ease-out,
                border-color .18s ease;
}

.story-episode.visible {
    opacity: 1;
    transform: translateY(0);
}

.story-episode:hover {
    border-color: var(--royal-gold);
    box-shadow: none;
}

/* Episode header */
.episode-header {
    padding: 20px 26px;
    background: var(--court-surface);
    border-bottom: 1px solid var(--court-line);
}

.episode-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 16px;
}

.episode-number {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--crimson-light);
}

.episode-date {
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 16px;
    color: var(--court-secondary);
}

.episode-title {
    font-family: 'Cinzel', Georgia, serif;
    color: var(--royal-gold-light);
    font-size: 21px;
    margin: 6px 0 0;
}

.episode-locations,
.episode-npcs {
    display: flex;
    align-items: center;
    margin-top: 12px;
    gap: 8px;
}

.episode-locations i,
.episode-npcs i { color: var(--royal-gold); }

.location-tags,
.npc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.location-tag,
.npc-tag {
    padding: 4px 12px;
    background: none;
    border: 1px solid var(--court-line);
    border-radius: 2px;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 15px;
    color: var(--court-secondary);
    transition: border-color .18s ease;
}

.story-episode:hover .location-tag,
.story-episode:hover .npc-tag { border-color: var(--court-border); }

/* A location chip whose place has a pin on the realm map links to it, in the
   gold the session page's linked chips use; one without a pin stays plain
   text, so the difference shows before the click rather than after. */
.location-tag-link {
    color: var(--royal-gold);
    text-decoration: none;
    transition: border-color .18s ease, background .18s ease, color .18s ease;
}

.location-tag-link:hover,
.location-tag-link:focus-visible {
    background: var(--court-hover);
    border-color: var(--royal-gold);
    color: var(--royal-gold-light);
}

/* Under the banner: the catch-up page, for a reader who wants the short
   version before the long one. */
.story-catchup { margin: 14px 0 0; }

.story-catchup a {
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--royal-gold);
    border-bottom: 1px solid var(--court-border);
    padding-bottom: 2px;
    transition: color .18s ease, border-color .18s ease;
}

.story-catchup a i { margin-right: 6px; }

.story-catchup a:hover,
.story-catchup a:focus-visible { color: var(--royal-gold-light); border-color: var(--royal-gold); }

/* A who-appears chip is a link to the person's card. */
a.npc-tag { text-decoration: none; }

a.npc-tag:hover,
a.npc-tag:focus-visible {
    color: var(--royal-gold-light);
    border-color: var(--royal-gold);
}

/* Under the recap: the session's own page, and the episode on YouTube. */
.episode-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    padding: 0 26px 22px;
}

.episode-footer a {
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--royal-gold);
    transition: color .18s ease;
}

.episode-footer a i { margin-right: 6px; }

.episode-footer a:hover,
.episode-footer a:focus-visible { color: var(--royal-gold-light); }

.episode-footer .episode-watch-link { color: var(--crimson-light); }

.episode-footer .episode-watch-link:hover,
.episode-footer .episode-watch-link:focus-visible { color: var(--parchment); }

/* Episode content */
.episode-content {
    padding: 26px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 26px;
}

.episode-content.with-image { grid-template-columns: 3fr 2fr; }

.episode-text {
    color: var(--parchment);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 19px;
    line-height: 1.75;
}

.episode-text p { margin-bottom: 14px; }

.episode-text p:last-child { margin-bottom: 0; }

.episode-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.episode-image {
    max-width: 100%;
    height: auto;
    border-radius: 0;
    border: 1px solid var(--court-line);
    box-shadow: none;
    transition: border-color .18s ease;
}

.story-episode:hover .episode-image { border-color: var(--court-border); }

.image-caption {
    text-align: center;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 16px;
    color: var(--court-secondary);
    margin-top: 10px;
}

/*
Loading indicators
*/
.loading-indicator {
    text-align: center;
    padding: 30px;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 18px;
    color: var(--court-secondary);
    opacity: 0;
    transition: opacity .4s ease;
}

.loading-indicator.active { opacity: 1; }

.spinner-d20 {
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
    position: relative;
}

.spinner-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--court-line);
    border-top-color: var(--royal-gold);
    animation: spin 1.5s ease-in-out infinite;
}

.top-loader { margin-bottom: 26px; }

.bottom-loader { margin-top: 26px; }

/*
No results
*/
.no-results-message {
    text-align: center;
    padding: 40px;
    margin: 26px auto;
    max-width: 540px;
    background: var(--court-raised);
    border: 1px solid var(--court-border);
    border-radius: 0;
}

.no-results-message i {
    font-size: 34px;
    color: var(--royal-gold);
    margin-bottom: 16px;
}

.no-results-message h3 {
    color: var(--royal-gold-light);
    margin-bottom: 14px;
}

.no-results-message p {
    color: var(--parchment);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 18px;
    margin-bottom: 22px;
}

.clear-search-btn {
    padding: 10px 20px;
    background: var(--crimson-dark);
    border: 1px solid var(--crimson-blood);
    border-radius: 2px;
    color: var(--parchment);
    font-family: 'Cinzel', Georgia, serif;
    font-size: 12px;
    letter-spacing: .12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .18s ease;
}

.clear-search-btn:hover { background: var(--crimson-blood); }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/*
Responsive
*/
@media (max-width: 992px) {
    .story-controls .container {
        flex-direction: column;
        align-items: stretch;
    }

    .act-navigation { justify-content: flex-start; }

    .story-search {
        width: 100%;
        margin-left: 0;
    }

    .story-search input { width: 100%; }

    .episode-content.with-image { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .dropdown-button,
    .dropdown-content,
    .dropdown-container { width: 100%; }

    .story-divider { flex-wrap: wrap; }

    .episode-header { padding: 16px; }

    .episode-content { padding: 16px; }

    .episode-text { font-size: 18px; }

    .episode-meta {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }
}
