/* ==========================================================
   mystory - gaya utama situs publik
   ========================================================== */

:root {
    --coral: #ff6b6b;
    --coral-dark: #ee5253;
    --orange: #ff9a56;
    --yellow: #ffd93d;
    --sky: #4dabf7;
    --purple: #a78bfa;
    --green: #51cf66;
    --ink: #2d2a3d;
    --ink-soft: #6b6880;
    --cream: #fff9f0;
    --card-bg: #ffffff;
    --border: #f0e6d6;
    --radius: 20px;
    --shadow: 0 8px 24px rgba(45, 42, 61, 0.08);
    --shadow-hover: 0 14px 32px rgba(45, 42, 61, 0.14);
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    font-size: 17px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
    font-family: 'Baloo 2', 'Nunito', system-ui, sans-serif;
    line-height: 1.25;
    margin: 0 0 .5em;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Baloo 2', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--coral-dark);
}
.brand-emoji { font-size: 1.6rem; }
.site-nav { display: flex; align-items: center; gap: 18px; font-weight: 700; }
.site-nav a { color: var(--ink-soft); padding: 6px 4px; }
.nav-admin {
    background: linear-gradient(135deg, var(--coral), var(--orange));
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 999px;
}

/* ---------- Language switcher ---------- */
.lang-switch {
    display: inline-flex;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}
.lang-switch a {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    color: var(--ink-soft) !important;
    line-height: 1;
}
.lang-switch a.lang-active {
    background: var(--ink);
    color: white !important;
}
.install-box .lang-switch {
    justify-content: center;
    margin: 0 auto 14px;
    width: fit-content;
}

/* ---------- Hero ---------- */
.hero {
    text-align: center;
    padding: 48px 20px 28px;
    background: radial-gradient(circle at 20% 0%, #fff2df 0%, var(--cream) 60%);
}
.hero h1 {
    font-size: clamp(2rem, 6vw, 2.8rem);
    color: var(--ink);
}
.wave { display: inline-block; animation: wave 2s ease-in-out infinite; }
@keyframes wave { 0%,100%{transform:rotate(0)} 25%{transform:rotate(15deg)} 75%{transform:rotate(-10deg)} }
.hero-tagline { color: var(--ink-soft); font-size: 1.1rem; margin-bottom: 24px; }

.search-bar {
    display: flex;
    max-width: 480px;
    margin: 0 auto 20px;
    gap: 8px;
}
.search-bar input {
    flex: 1;
    padding: 14px 18px;
    border-radius: 999px;
    border: 2px solid var(--border);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}
.search-bar input:focus { border-color: var(--coral); }
.search-bar button {
    padding: 14px 20px;
    border-radius: 999px;
    border: none;
    background: var(--coral);
    color: white;
    font-weight: 700;
    cursor: pointer;
}
.search-bar button:hover { background: var(--coral-dark); }

.genre-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
.chip {
    background: var(--card-bg);
    border: 2px solid var(--border);
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .9rem;
    white-space: nowrap;
}
.chip:hover { border-color: var(--orange); }
.chip-active {
    background: var(--ink);
    border-color: var(--ink);
    color: white;
}

/* ---------- Story grid ---------- */
.story-grid-section { padding: 32px 20px 60px; }
.story-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.story-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
    display: flex;
    flex-direction: column;
}
.story-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}
.story-cover {
    position: relative;
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.story-cover img { width: 100%; height: 100%; object-fit: cover; }
.story-cover-emoji { font-size: 3.2rem; }
.story-genre-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255,255,255,.92);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    color: var(--ink);
}
.story-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.story-body h3 { font-size: 1.15rem; margin-bottom: 6px; }
.story-excerpt { color: var(--ink-soft); font-size: .92rem; flex: 1; margin: 0 0 10px; }
.story-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: .8rem;
    color: var(--ink-soft);
    font-weight: 700;
}

/* ---------- Empty / not found ---------- */
.empty-state, .not-found {
    text-align: center;
    padding: 60px 20px;
    color: var(--ink-soft);
}
.empty-emoji { font-size: 3.5rem; margin-bottom: 12px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 32px; }
.page-link {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    font-weight: 700;
}
.page-active { background: var(--coral); border-color: var(--coral); color: white; }

/* ---------- Buttons (shared) ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 22px;
    border-radius: 999px;
    border: none;
    font-weight: 800;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
}
.btn-primary { background: linear-gradient(135deg, var(--coral), var(--orange)); color: white; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--card-bg); border: 2px solid var(--border); color: var(--ink); }
.btn-block { width: 100%; margin-top: 10px; }
.btn-big { padding: 16px 26px; font-size: 1.1rem; }

/* ---------- Alerts ---------- */
.alert { border-radius: 14px; padding: 14px 18px; margin-bottom: 18px; font-weight: 700; }
.alert ul { margin: 0; padding-left: 20px; font-weight: 600; }
.alert-error { background: #ffe3e3; color: #c92a2a; }
.alert-success { background: #d3f9d8; color: #2b8a3e; }

/* ---------- Story reader ---------- */
.story-reader { padding: 28px 20px 40px; max-width: 760px; }
.back-link { display: inline-block; margin-bottom: 16px; font-weight: 700; color: var(--coral-dark); }
.reader-cover {
    border-radius: var(--radius);
    aspect-ratio: 16/9;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    margin-bottom: 18px;
}
.reader-cover img { width: 100%; height: 100%; object-fit: cover; }
.reader-cover-emoji { font-size: 5rem; }
.reader-badge { position: static; display: inline-flex; margin-bottom: 10px; }
.reader-title { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.reader-meta { margin-bottom: 18px; }
.reader-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    width: fit-content;
    margin-bottom: 22px;
    font-weight: 700;
    font-size: .85rem;
}
.reader-tools button {
    border: none;
    background: var(--cream);
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 800;
}
.reader-content {
    font-size: 1.15rem;
    line-height: 1.85;
    white-space: pre-wrap;
}
.more-stories { padding: 20px 20px 60px; }

/* Dark mode reading (toggle via JS, class on body) */
body.reader-dark {
    background: #1b1a24;
    color: #eae7f5;
}
body.reader-dark .story-reader .reader-content,
body.reader-dark .reader-title { color: #f2f0fb; }
body.reader-dark .reader-tools,
body.reader-dark .reader-tools button { background: #2a2836; color: #eae7f5; }
body.reader-dark .site-header,
body.reader-dark .site-footer { background: #201f2b; border-color: #34324450; }
body.reader-dark .brand, body.reader-dark .site-nav a { color: #eae7f5; }

/* ---------- Footer ---------- */
.site-footer {
    text-align: center;
    padding: 26px 20px;
    color: var(--ink-soft);
    font-size: .9rem;
}

/* ---------- Install / Login box ---------- */
.install-page {
    background: linear-gradient(160deg, #fff2df, var(--cream));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.install-box {
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow-hover);
    padding: 36px 30px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.install-emoji { font-size: 2.8rem; margin-bottom: 8px; }
.install-sub { color: var(--ink-soft); margin-bottom: 20px; }
.install-note { font-size: .85rem; color: var(--ink-soft); text-align: left; }
.install-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.install-form label, .settings-form label, .story-form label {
    font-weight: 800;
    font-size: .92rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.install-form input, .settings-form input, .settings-form select,
.story-form input, .story-form select, .story-form textarea {
    font-family: inherit;
    font-size: 1rem;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid var(--border);
    outline: none;
}
.install-form input:focus, .settings-form input:focus, .story-form textarea:focus,
.story-form input:focus, .story-form select:focus { border-color: var(--coral); }
.opt { font-weight: 500; color: var(--ink-soft); font-size: .82rem; }

/* Responsive */
@media (max-width: 900px) {
    .story-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .story-grid { grid-template-columns: 1fr; }
    .header-inner { padding: 12px 16px; }
    .site-nav { gap: 10px; }
    .brand-text { display: none; }
    .hero { padding: 32px 16px 22px; }
}
