/* ============================================================
   create.css — story creation page specific styles
   ============================================================ */

body {
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-width: 320px;
}

.header {
    max-width: 1000px;
    width: 100%;
}

.nav-button.dashboard {
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-mid) 100%);
    color: white;
}

.nav-button.dashboard:hover {
    opacity: 0.9;
}

.nav-button.logout {
    background: var(--green-pale);
    color: var(--green-text);
    border: 1px solid var(--green-border);
}

.nav-button.logout:hover {
    background: var(--green-hover);
}

.nav-button.login {
    background: var(--green-pale);
    color: var(--green-text);
    border: 1px solid var(--green-border);
}

.nav-button.login:hover {
    background: var(--green-hover);
}

.nav-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* Main layout */
.main-container {
    display: flex;
    justify-content: center;
    flex: 1;
}

.container {
    max-width: 800px;
    width: 100%;
    height: fit-content;
}

h1 {
    margin-bottom: 30px;
}

/* Form inputs */
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--green-border);
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
    resize: vertical;
    min-height: 80px;
}

textarea:focus {
    outline: none;
    border-color: var(--green-mid);
    box-shadow: 0 0 0 3px rgba(30, 102, 68, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    padding: 0;
    accent-color: var(--green-mid);
}

.button-group {
    display: flex;
    gap: 10px;
}

/* Story output */
.story-output {
    margin-top: 30px;
    padding: 20px;
    background: var(--green-pale);
    border-radius: 5px;
    display: none;
    border: 1px solid var(--green-border);
}

.story-output.visible {
    display: block;
}

.story-output h2 {
    color: var(--green-dark);
    margin-bottom: 15px;
    font-size: 20px;
    font-family: 'Fraunces', serif;
}

.story-content {
    color: var(--green-text);
    line-height: 1.6;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.story-metadata {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--green-border);
    font-size: 12px;
    color: var(--green-muted);
}

.story-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.story-actions button {
    margin: 0;
    padding: 8px 12px;
    font-size: 13px;
}

.story-actions button.hidden {
    display: none !important;
}

.save-success {
    padding: 10px;
    margin-top: 10px;
    background: var(--green-light);
    border: 1px solid var(--green-border);
    border-radius: 5px;
    color: var(--green-mid);
    font-size: 13px;
}

.save-progress {
    padding: 12px 16px;
    margin-top: 10px;
    background: var(--green-light);
    border: 1px solid var(--green-border);
    border-radius: 5px;
    color: var(--green-text);
    font-size: 13px;
    display: none;
}

.save-progress.visible {
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--green-border);
    border-top-color: var(--green-mid);
    border-radius: 50%;
    flex-shrink: 0;
    animation: spin 0.8s linear infinite;
}

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

/* Story rating */
.story-rating {
    margin-top: 14px;
    display: none;
}

.story-rating.visible {
    display: block;
}

.story-rating label {
    font-size: 13px;
    color: var(--green-muted);
    margin-bottom: 8px;
    display: block;
}

.rating-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rating-btn {
    background: var(--green-pale);
    border: 2px solid var(--green-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 18px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    line-height: 1;
    width: auto;
    margin-top: 0;
}

.rating-btn:hover {
    background: var(--green-light);
    border-color: var(--green-border);
}

.rating-btn.selected {
    background: var(--green-light);
    border-color: var(--green-mid);
}

/* Error & loading overrides */
.error {
    padding: 15px;
    margin-top: 20px;
    margin-bottom: 0;
}

/* Auth prompt */
.auth-prompt {
    padding: 15px;
    margin-top: 15px;
    background: var(--green-light);
    border: 1px solid var(--green-border);
    border-radius: 5px;
    color: var(--green-dark);
    display: none;
    text-align: center;
}

.auth-prompt.visible {
    display: block;
}

.auth-prompt p {
    margin-bottom: 10px;
    font-size: 14px;
}

.auth-prompt-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.auth-prompt-buttons button {
    margin: 0;
    padding: 10px 16px;
    font-size: 13px;
    flex: 0 1 auto;
}

/* Child context */
.child-context {
    margin-bottom: 20px;
    padding: 14px;
    background: var(--green-pale);
    border: 1px solid var(--green-border);
    border-radius: 8px;
    display: none;
}

.child-context.visible {
    display: block;
}

.child-context h3 {
    font-size: 15px;
    margin-bottom: 10px;
    color: var(--green-dark);
    font-family: 'Fraunces', serif;
}

.child-context-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.child-context-row select {
    flex: 1;
    min-width: 220px;
}

.child-context-row button {
    margin: 0;
    padding: 10px 14px;
    font-size: 13px;
    flex: 0 0 auto;
}

.child-context-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--green-muted);
}

/* Char counter */
.char-counter {
    font-size: 12px;
    color: var(--green-muted);
    text-align: right;
    margin-top: 4px;
}

.char-counter.near-limit {
    color: #e67e22;
}

.char-counter.at-limit {
    color: #c33;
    font-weight: 600;
}

/* Help expand button */
.help-expand-btn {
    width: 100%;
    background: none;
    border: 1px dashed var(--green-border);
    border-radius: 8px;
    color: var(--green-mid);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: left;
    transition: background 0.2s, border-color 0.2s;
    transform: none !important;
    box-shadow: none !important;
}

.help-expand-btn:hover {
    background: var(--green-pale);
    border-color: var(--green-mid);
}

/* Auth wall */
.auth-wall {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.auth-wall.visible {
    display: block;
}

.auth-wall h2 {
    color: var(--green-dark);
    font-size: 22px;
    margin-bottom: 10px;
    font-family: 'Fraunces', serif;
}

.auth-wall p {
    color: var(--green-muted);
    font-size: 15px;
    margin-bottom: 30px;
}

.auth-wall-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.auth-wall-buttons button {
    flex: 0 1 auto;
    padding: 12px 28px;
    font-size: 15px;
    margin: 0;
}

.auth-wall-buttons .btn-secondary {
    background: var(--green-pale);
    color: var(--green-text);
    border: 1px solid var(--green-border);
}

.auth-wall-buttons .btn-secondary:hover {
    background: var(--green-hover);
    box-shadow: none;
}

/* ============================================================
   Storybook generation interstitial
   ============================================================ */

.sb-interstitial {
    margin-top: 30px;
    padding: 40px 28px 32px;
    background: linear-gradient(160deg, var(--green-dark) 0%, var(--green-primary) 100%);
    border-radius: 16px;
    text-align: center;
    color: #E8F5EF;
    position: relative;
    overflow: hidden;
}

/* Subtle radial glow in the bg */
.sb-interstitial::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(184,216,200,0.12) 0%, transparent 65%);
    pointer-events: none;
}

/* Book illustration */
.sb-illus-wrap {
    position: relative;
    width: 140px;
    height: 96px;
    margin: 0 auto 28px;
}

.sb-book {
    width: 140px;
    height: 96px;
    filter: drop-shadow(0 10px 24px rgba(0,0,0,0.35));
    animation: sb-book-float 3.2s ease-in-out infinite;
}

@keyframes sb-book-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-7px); }
}

/* Floating sparkles */
.sb-sparkle {
    position: absolute;
    color: #B8D8C8;
    animation: sb-sparkle-rise ease-in-out infinite;
    pointer-events: none;
    line-height: 1;
}
.sb-s1 { top: -10px; left: 14px;  font-size: 15px; animation-duration: 2.8s; animation-delay: 0s;   }
.sb-s2 { top:   8px; right: 8px;  font-size: 10px; animation-duration: 3.3s; animation-delay: 0.7s; }
.sb-s3 { bottom: 6px; left: 0;    font-size: 12px; animation-duration: 2.6s; animation-delay: 1.3s; }
.sb-s4 { bottom: 2px; right: 18px;font-size: 18px; animation-duration: 3.8s; animation-delay: 2.0s; }

@keyframes sb-sparkle-rise {
    0%, 100% { transform: translateY(0)   scale(1);   opacity: 0.6; }
    50%       { transform: translateY(-12px) scale(1.25); opacity: 1;   }
}

/* Phase title & subtitle */
.sb-phase-title {
    font-family: 'Fraunces', serif;
    font-size: 1.45rem;
    font-weight: 600;
    color: #E8F5EF;
    margin: 0 0 10px;
    transition: opacity 0.5s ease;
}

.sb-phase-sub {
    font-size: 14px;
    color: #7ABDA0;
    line-height: 1.65;
    max-width: 440px;
    margin: 0 auto 26px;
    min-height: 46px;
    transition: opacity 0.5s ease;
}

/* Progress bar */
.sb-progress-wrap {
    max-width: 420px;
    margin: 0 auto 18px;
}

.sb-progress-track {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 7px;
}

.sb-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #52B788, #B7E4C7);
    border-radius: 100px;
    transition: width 1s ease;
    position: relative;
}

/* Shimmer on the fill bar */
.sb-progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: sb-shimmer 2s linear infinite;
}

@keyframes sb-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

.sb-progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #5A8A72;
}

/* Time hint */
.sb-time-hint {
    font-size: 12px;
    color: #4A6B5A;
    max-width: 400px;
    margin: 0 auto 14px;
    line-height: 1.65;
}

.sb-time-hint strong {
    color: #7ABDA0;
}

/* Live page count */
.sb-page-status {
    font-size: 13px;
    color: #7ABDA0;
    min-height: 20px;
    font-style: italic;
}

/* Page tile grid — shows each page slot lighting up as it completes */
.sb-page-grid {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 440px;
    margin: 4px auto 14px;
}

.sb-page-tile {
    width: 40px;
    height: 48px;
    border-radius: 4px 8px 8px 4px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}

/* Small status dot at the top of each tile */
.sb-page-tile::before {
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    transition: background 0.3s, box-shadow 0.3s;
    flex-shrink: 0;
}

.sb-page-tile-num {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.2);
    transition: color 0.3s;
}

.sb-page-tile.done {
    background: rgba(82,183,136,0.18);
    border-color: rgba(82,183,136,0.5);
    transform: scale(1.06);
}

.sb-page-tile.done::before {
    background: #74C69D;
    box-shadow: 0 0 7px rgba(116,198,157,0.7);
}

.sb-page-tile.done .sb-page-tile-num {
    color: rgba(255,255,255,0.85);
}

@keyframes tilePop {
    0%   { transform: scale(0.8); opacity: 0.3; }
    60%  { transform: scale(1.13); }
    100% { transform: scale(1.06); opacity: 1; }
}

.sb-page-tile.pop {
    animation: tilePop 0.4s ease forwards;
}
