/* FRONT-END INTERACTIVE STORYBOOK PLAYER STYLES */

.ifs-shell-container {
    --bg:        #fdfbf7;
    --bg-2:      #f5edd6;
    --ink:       #2d251e;
    --ink-soft:  #756657;
    --accent:    #e07a3c;
    --accent-2:  #b95622;
    --card:      #ffffff;
    --shadow:    0 15px 40px rgba(78, 55, 30, 0.12);
    --radius:    24px;
    
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background:
      radial-gradient(ellipse at top left, rgba(224,122,60,0.08) 0%, transparent 50%),
      radial-gradient(ellipse at bottom right, rgba(185,86,34,0.07) 0%, transparent 55%),
      var(--bg);
    border: 1px solid rgba(224, 122, 60, 0.12);
    border-radius: var(--radius);
    overflow: hidden;
    max-width: 900px;
    margin: 40px auto;
    box-shadow: var(--shadow);
    box-sizing: border-box;
}

.ifs-shell-container * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.ifs-display {
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

.ifs-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ---------- Header ---------- */
.ifs-player-header {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(224, 122, 60, 0.12);
    background: rgba(253, 251, 247, 0.85);
    backdrop-filter: blur(8px);
}

.ifs-player-header h1 {
    margin: 0;
    font-size: clamp(16px, 2.2vw, 20px);
    font-weight: 700;
    color: var(--ink);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 75%;
    border: none;
}

.ifs-settings {
    position: absolute;
    right: 18px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 999px;
    user-select: none;
    transition: background 0.2s ease;
}

.ifs-settings:hover {
    background: rgba(224, 122, 60, 0.08);
}

.ifs-settings input {
    accent-color: var(--accent);
    margin: 0;
    cursor: pointer;
}

/* ---------- Stage (image + text) ---------- */
.ifs-stage {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto auto;
    gap: 20px;
    padding: 24px 20px;
    align-items: center;
}

@media (min-width: 768px) {
    .ifs-stage {
        grid-template-rows: 1fr;
        grid-template-columns: 1.15fr 0.85fr;
        gap: 32px;
        padding: 36px 40px;
        min-height: 460px;
    }
}

.ifs-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5; /* Default aspect ratio */
    overflow: hidden;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(78, 55, 30, 0.08);
    background: var(--card);
}

/* Force standard aspect ratios */
.ifs-shell-container[data-aspect-ratio="16:9"] .ifs-image-wrap {
    aspect-ratio: 16 / 9;
}
.ifs-shell-container[data-aspect-ratio="4:5"] .ifs-image-wrap {
    aspect-ratio: 4 / 5;
}
.ifs-shell-container[data-aspect-ratio="3:4"] .ifs-image-wrap {
    aspect-ratio: 3 / 4;
}
.ifs-shell-container[data-aspect-ratio="1:1"] .ifs-image-wrap {
    aspect-ratio: 1 / 1;
}

.ifs-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* crop to fill perfectly without letterboxing */
    transition: opacity 0.35s ease;
}

.ifs-image-wrap.ifs-fading img {
    opacity: 0;
}

/* Cover page: Full illustration layout */
.ifs-stage.cover {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.ifs-stage.cover .ifs-text-wrap {
    display: none;
}

.ifs-stage.cover .ifs-image-wrap {
    max-width: 480px;
    margin: 0 auto;
}

.ifs-text-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.ifs-text-wrap p {
    margin: 0;
    text-align: center;
    line-height: 1.75;
    color: var(--ink);
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
    font-size: clamp(16px, 2vw, 22px);
    transition: opacity 0.35s ease;
    max-width: 34ch;
}

.ifs-stage.ifs-fading .ifs-text-wrap p {
    opacity: 0;
}

/* ---------- Footer (controls) ---------- */
.ifs-player-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(224, 122, 60, 0.12);
    background: rgba(253, 251, 247, 0.94);
}

.ifs-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 4px 0 16px;
    flex-wrap: wrap;
}

.ifs-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    background: rgba(224, 122, 60, 0.22);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ifs-dot.done {
    background: var(--accent);
    opacity: 0.75;
}

.ifs-dot.active {
    width: 14px;
    height: 14px;
    background: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(224, 122, 60, 0.25);
    opacity: 1;
}

.ifs-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.ifs-nav-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(224, 122, 60, 0.25);
    background: #fff;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.ifs-nav-btn:hover:not(:disabled) {
    background: var(--bg-2);
    border-color: var(--accent);
}

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

.ifs-play-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(224, 122, 60, 0.3);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
    padding: 0;
}

.ifs-play-btn:hover {
    background: var(--accent-2);
    transform: scale(1.06);
}

.ifs-play-btn:active {
    transform: scale(0.96);
}

/* ---------- End screen ---------- */
.ifs-end {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    gap: 18px;
    min-height: 380px;
}

.ifs-end.show {
    display: flex;
}

.ifs-end .ifs-star {
    font-size: 64px;
    line-height: 1;
    animation: pulse-star 2s infinite ease-in-out;
}

@keyframes pulse-star {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.ifs-end h2 {
    margin: 0;
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 800;
    color: var(--ink);
}

.ifs-end p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 18px;
}

.ifs-end .ifs-btn {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(224, 122, 60, 0.35);
    transition: background 0.2s ease, transform 0.15s ease;
}

.ifs-end .ifs-btn:hover {
    background: var(--accent-2);
    transform: translateY(-1px);
}

.ifs-hidden {
    display: none !important;
}

.ifs-error-msg {
    padding: 20px;
    background: #fff4f4;
    border: 1px solid #f5c2c2;
    color: #b33a3a;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
}

.ifs-shell-container svg {
    display: block;
    margin: 0 auto;
}
