/* ============================================
   Дивные сказки — Fairy Tale Website Styles
   ============================================ */

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

:root {
    --bg-deep: #0a0618;
    --bg-dark: #110d28;
    --bg-card: #1a1335;
    --bg-card-hover: #231a45;
    --gold: #F5E6B8;
    --gold-dim: #C4A86A;
    --gold-glow: rgba(245, 230, 184, 0.15);
    --purple-light: #B8A9D4;
    --purple-accent: #7B5EA7;
    --text-primary: #EDE6F5;
    --text-secondary: #9B8EC4;
    --border: rgba(184, 169, 212, 0.12);
    --radius: 12px;
    --radius-lg: 20px;
    --font-display: 'Comfortaa', cursive;
    --font-body: 'Nunito', sans-serif;
    --font-hand: 'Caveat', cursive;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --transition: 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--gold);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--gold-dim);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section {
    padding: 60px 0;
}

/* ---- Animated Stars Background ---- */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.tiny-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--gold);
    border-radius: 50%;
    animation: twinkle var(--dur) ease-in-out infinite alternate;
    opacity: 0;
}

@keyframes twinkle {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: var(--max-o); transform: scale(1); }
}

/* ---- Header ---- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 6, 24, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    height: 64px;
    gap: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 1.6rem;
    color: var(--gold);
    animation: star-pulse 3s ease-in-out infinite;
}

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

.logo-text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-accent {
    color: var(--gold);
}

.main-nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav-link {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 8px;
    transition: all var(--transition);
}
.nav-link:hover,
.nav-link.active {
    color: var(--gold);
    background: var(--gold-glow);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.user-greeting {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--purple-light);
}

/* Mobile menu */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--gold);
    border-radius: 2px;
    transition: all 0.3s;
}

.mobile-nav {
    display: none;
    flex-direction: column;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: rgba(10, 6, 24, 0.95);
}
.mobile-nav.open {
    display: flex;
}
.mobile-nav-link {
    font-family: var(--font-display);
    color: var(--text-secondary);
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.mobile-nav-link:hover {
    color: var(--gold);
}

@media (max-width: 768px) {
    .main-nav, .header-actions { display: none; }
    .mobile-menu-btn { display: flex; }
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    padding: 10px 24px;
    font-size: 0.95rem;
    white-space: nowrap;
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold-dim), var(--gold));
    color: var(--bg-deep);
    box-shadow: 0 4px 15px rgba(245, 230, 184, 0.25);
}
.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(245, 230, 184, 0.35);
    color: var(--bg-deep);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--gold-dim);
    color: var(--gold);
    background: var(--gold-glow);
}

.btn-outline-light {
    background: transparent;
    border: 1.5px solid rgba(245, 230, 184, 0.3);
    color: var(--gold);
}
.btn-outline-light:hover {
    border-color: var(--gold);
    background: rgba(245, 230, 184, 0.1);
    color: var(--gold);
}

.btn-danger {
    background: rgba(220, 50, 50, 0.15);
    border: 1px solid rgba(220, 50, 50, 0.3);
    color: #E86B6B;
}
.btn-danger:hover {
    background: rgba(220, 50, 50, 0.25);
    color: #FF8A8A;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.1rem;
    border-radius: 14px;
}

.btn-full {
    width: 100%;
}

/* ---- Hero ---- */
.hero {
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: center;
    overflow: hidden;
    z-index: 1;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 80%, rgba(123, 94, 167, 0.2) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(245, 230, 184, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 20% 50%, rgba(70, 50, 140, 0.15) 0%, transparent 50%);
}

.hero-content {
    position: relative;
    text-align: center;
    padding: 80px 20px;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
}
.hero-title-line {
    display: block;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--text-primary);
}
.hero-title-accent {
    color: var(--gold);
    text-shadow: 0 0 40px rgba(245, 230, 184, 0.3);
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto 36px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.hero-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.hero-star {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-size: calc(1.2rem * var(--s));
    color: var(--gold);
    opacity: 0.4;
    animation: hero-float var(--d) ease-in-out infinite alternate;
}
@keyframes hero-float {
    0% { transform: translateY(0) scale(1); opacity: 0.3; }
    100% { transform: translateY(-15px) scale(1.1); opacity: 0.6; }
}

.hero-moon {
    position: absolute;
    top: 30px;
    right: 40px;
    width: 120px;
    height: 120px;
    opacity: 0.25;
    pointer-events: none;
}
.moon-svg {
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .hero { min-height: 60vh; }
    .hero-content { padding: 60px 20px; }
    .hero-moon { display: none; }
}

/* ---- Section Headers ---- */
.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
}

.section-divider {
    margin-top: 12px;
    color: var(--gold-dim);
    font-size: 1.4rem;
}
.divider-star {
    opacity: 0.5;
}

.section-footer {
    text-align: center;
    margin-top: 40px;
}

/* ---- Tales Grid ---- */
.tales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 28px;
}

.tale-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.4s ease;
    text-decoration: none;
}
.tale-card:hover {
    transform: translateY(-6px);
    border-color: rgba(245, 230, 184, 0.25);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(245, 230, 184, 0.08);
}

.tale-card-cover {
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--bg-dark);
}
.cover-iframe {
    width: 200%;
    height: 200%;
    border: none;
    transform: scale(0.5);
    transform-origin: top left;
    pointer-events: none;
}

.cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.9rem;
    padding: 20px;
    text-align: center;
}
.cover-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.tale-card-body {
    padding: 16px 20px 20px;
}

.tale-card-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tale-card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.tale-card-age {
    display: inline-block;
    background: var(--gold-glow);
    color: var(--gold);
    font-family: var(--font-display);
    font-size: 0.75rem;
    padding: 3px 12px;
    border-radius: 20px;
    border: 1px solid rgba(245, 230, 184, 0.15);
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 48px;
}

.pagination-btn {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--gold);
    padding: 8px 20px;
    border: 1px solid rgba(245, 230, 184, 0.2);
    border-radius: 10px;
    transition: all var(--transition);
}
.pagination-btn:hover {
    background: var(--gold-glow);
    border-color: var(--gold-dim);
}

.pagination-info {
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.85rem;
}

/* ---- Auth Pages ---- */
.auth-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.auth-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--gold);
    text-align: center;
    margin-bottom: 28px;
}

.auth-error {
    background: rgba(220, 50, 50, 0.1);
    border: 1px solid rgba(220, 50, 50, 0.25);
    color: #E86B6B;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ---- Forms ---- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--purple-light);
}

.form-input {
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
    outline: none;
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 3px rgba(245, 230, 184, 0.1);
}
.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239B8EC4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* ---- About Page ---- */
.about-inner {
    max-width: 700px;
    margin: 0 auto;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.about-block h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--gold);
    margin-bottom: 12px;
}

.about-block p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.about-block ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.about-block li {
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 20px;
    position: relative;
}
.about-block li::before {
    content: '\2726';
    position: absolute;
    left: 0;
    color: var(--gold-dim);
}

.about-teaser {
    background: linear-gradient(180deg, transparent, rgba(123, 94, 167, 0.06), transparent);
}
.about-teaser-inner {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}
.about-teaser-text h2 {
    margin-bottom: 16px;
}
.about-teaser-text p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 24px;
}

/* ---- Back link ---- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    transition: color var(--transition);
}
.back-link:hover {
    color: var(--gold);
}

/* ---- Admin ---- */
.admin-section {
    padding-top: 30px;
}

.admin-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
}

.admin-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
}
.admin-stat-num {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
}
.admin-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.admin-actions-bar {
    margin-bottom: 20px;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table th {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--purple-light);
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.admin-table tr:hover td {
    background: rgba(255,255,255,0.02);
}
.admin-tale-link {
    color: var(--text-primary);
    font-weight: 600;
}
.admin-tale-link:hover {
    color: var(--gold);
}
.admin-slug {
    font-family: monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    opacity: 0.7;
}
.admin-actions-cell {
    display: flex;
    gap: 8px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-family: var(--font-display);
}
.badge-green {
    background: rgba(50, 200, 100, 0.1);
    color: #6FCF97;
    border: 1px solid rgba(50, 200, 100, 0.2);
}
.badge-yellow {
    background: rgba(245, 230, 100, 0.1);
    color: #E8D44D;
    border: 1px solid rgba(245, 230, 100, 0.2);
}

/* ---- Footer ---- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    margin-top: 40px;
    position: relative;
    z-index: 1;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-copy {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
    background: rgba(123, 94, 167, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(123, 94, 167, 0.5);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .tales-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
    }
    .auth-card {
        padding: 28px 20px;
        margin: 0 12px;
}
    .admin-stats {
        flex-direction: column;
    }
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}