/* KT_VERSION:15 */
:root {
    --maroon: #5b1a21;
    --maroon-dark: #431217;
    --gold: #d4a04a;
    --cream: #faf4e8;
    --cream-dark: #f0e6d2;
    --ink: #2c2420;
    --muted: #7a6f63;
    --radius: 14px;
    --sidebar-w: 300px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: 'Poppins', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

a { color: inherit; text-decoration: none; }

.kt-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- Header ---------- */
.kt-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: var(--maroon);
    color: var(--cream);
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.kt-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}
.kt-menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--cream);
    border-radius: 2px;
}

.kt-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.kt-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}
.kt-brand-title {
    display: block;
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.kt-brand-tagline {
    display: block;
    font-size: 0.78rem;
    color: var(--gold);
    font-style: italic;
}

.kt-email-sub {
    margin-left: auto;
    position: relative;
    flex-shrink: 0;
}

.kt-bell-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.kt-bell-btn:hover { background: rgba(255,255,255,0.22); }
.kt-bell-btn.is-subscribed { background: var(--gold); color: var(--maroon-dark); }

.kt-email-popover {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: #fff;
    color: var(--ink);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    z-index: 45;
}
.kt-email-popover.is-open { display: block; }
.kt-email-popover p { margin: 0 0 10px; font-size: 0.85rem; color: var(--muted); }
.kt-email-popover input[type=email] {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #e6ddca);
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 10px;
}
.kt-btn-email-submit {
    width: 100%;
    padding: 9px;
    border-radius: 8px;
    border: none;
    background: var(--maroon);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
}
.kt-btn-email-submit:hover { background: var(--maroon-dark); }
.kt-email-msg { font-size: 0.8rem; margin: 8px 0 0 !important; min-height: 1em; }
.kt-email-msg.is-error { color: #b23b3b; }
.kt-email-msg.is-ok { color: #3b6b4f; }

@media (max-width: 480px) {
    .kt-email-popover { right: -60px; width: 240px; }
}

/* ---------- Body layout ---------- */
.kt-body {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}

.kt-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--cream-dark);
    border-right: 1px solid rgba(0,0,0,0.06);
    overflow-y: auto;
}
.kt-sidebar-inner { padding: 18px 10px; }

.kt-sidebar-loading, .kt-sidebar-empty {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 10px 12px;
}

.kt-cat {
    margin-bottom: 6px;
    border-radius: 10px;
    overflow: hidden;
}
.kt-cat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    border-radius: 10px;
    color: var(--ink);
    transition: background 0.15s ease;
}
.kt-cat-btn:hover { background: rgba(0,0,0,0.045); }
.kt-cat-btn.is-open { background: rgba(0,0,0,0.06); }

.kt-cat-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kt-cat-name { flex: 1; }
.kt-cat-chevron {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
    flex-shrink: 0;
}
.kt-cat-btn.is-open .kt-cat-chevron { transform: rotate(45deg); }

/* the collapsible container - can hold nested subcategory blocks and/or a poem list */
.kt-poem-list {
    margin: 2px 0 8px 0;
    padding: 0 4px 0 22px;
    display: none;
}
.kt-poem-list.is-open { display: block; }

/* nested subcategory blocks sit one level in, with a lighter visual weight than the parent */
.kt-cat-nested { margin-bottom: 4px; }
.kt-cat-nested > .kt-cat-btn { font-size: 0.92rem; font-weight: 500; padding: 9px 10px; }
.kt-cat-nested .kt-cat-dot { width: 9px; height: 9px; }
.kt-cat-nested > .kt-poem-list { padding-left: 18px; }

.kt-poem-ul { list-style: none; margin: 0; padding: 0; }
.kt-poem-ul li { margin: 0; }
.kt-poem-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 0.92rem;
    color: var(--muted);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}
.kt-poem-link:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
.kt-poem-link.is-active {
    color: var(--ink);
    font-weight: 600;
    background: rgba(0,0,0,0.06);
}

/* red "new item" indicator - used on category buttons and poem links alike */
.kt-new-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d8453a;
    box-shadow: 0 0 0 2px #fff;
    flex-shrink: 0;
}
.kt-cat-btn .kt-new-dot { margin-left: -2px; }

.kt-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 20;
}

/* ---------- Main / poem view ---------- */
.kt-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 40px 24px 60px;
    display: flex;
    justify-content: center;
}

.kt-welcome {
    max-width: 520px;
    text-align: center;
    margin-top: 8vh;
    color: var(--muted);
}
.kt-welcome-icon { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 18px; }
.kt-welcome h1 {
    font-family: 'Playfair Display', serif;
    color: var(--maroon);
    font-size: 2.1rem;
    margin: 0 0 8px;
}
.kt-welcome-hint { font-size: 0.9rem; margin-top: 18px; }

.kt-poem {
    width: 100%;
    max-width: 720px;
}

.kt-poem-card-wrap {
    position: relative; /* anchors the forward button/popover without the card's own
                            overflow:hidden (used for its background image) clipping them
                            when the card is shorter than the popover */
}

.kt-poem-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    box-shadow: 0 6px 24px rgba(43, 30, 20, 0.08);
    padding: 44px 40px;
    background-size: cover;
    background-position: center;
}
.kt-poem-card.has-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 252, 246, 0.86);
    z-index: 0;
}
.kt-poem-card > * { position: relative; z-index: 1; }

.kt-forward-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.85);
    color: var(--maroon);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}
.kt-forward-btn:hover { background: #fff; }

.kt-forward-popover {
    display: none;
    position: absolute;
    top: 56px;
    right: 18px;
    z-index: 3;
    width: 260px;
    background: #fff;
    color: var(--ink);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    text-align: left;
}
.kt-forward-popover.is-open { display: block; }
.kt-forward-popover h4 { margin: 0 0 10px; font-family: 'Playfair Display', serif; color: var(--maroon); font-size: 1rem; }
.kt-forward-popover label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
}
.kt-forward-popover input, .kt-forward-popover textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e6ddca;
    font-family: inherit;
    font-size: 0.88rem;
    margin-top: 4px;
    resize: vertical;
}
.kt-forward-honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px; height: 1px;
    overflow: hidden;
}

@media (max-width: 480px) {
    .kt-forward-popover { right: -8px; width: 240px; }
}

.kt-poem-category {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 999px;
    color: #fff;
    margin-bottom: 16px;
}

.kt-poem-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.9rem;
    margin: 0 0 22px;
    color: var(--maroon);
    line-height: 1.3;
}

.kt-listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(91, 26, 33, 0.25);
    background: transparent;
    color: var(--maroon);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.kt-listen-btn:hover, .kt-listen-btn.is-open { background: var(--maroon); color: #fff; }

.kt-poem-audio,
.kt-poem-song {
    display: block;
    width: 100%;
    margin: 0 0 20px;
}
.kt-poem-audio[hidden],
.kt-poem-song[hidden] { display: none; }

/* Listen / Song buttons sit side by side; each reveals its own player underneath. */
.kt-audio-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: -10px 0 16px;
}

.kt-poem-content {
    font-size: 1.15rem;
    line-height: 2;
    color: var(--ink);
}
.kt-poem-content p { margin: 0 0 1.1em; }

/* A poem that's just an image with the text already embedded in it (no typed content) -
   shown whole and resized to fit, never cropped, unlike the cover-style background image. */
.kt-poem-image-full {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 10px;
}

/* ---------- Poem prev/next nav ---------- */
.kt-poem-nav {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-top: 18px;
}
.kt-poem-nav-spacer { flex: 1; }
.kt-poem-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    text-align: left;
    box-shadow: 0 3px 12px rgba(43, 30, 20, 0.05);
    transition: background 0.15s ease, transform 0.15s ease;
    min-width: 0;
}
.kt-poem-nav-btn:hover { background: var(--cream-dark); transform: translateY(-1px); }
.kt-poem-nav-next { justify-content: flex-end; text-align: right; }
.kt-poem-nav-arrow {
    font-size: 1.6rem;
    line-height: 1;
    color: var(--maroon);
    flex-shrink: 0;
}
.kt-poem-nav-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.kt-poem-nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}
.kt-poem-nav-title {
    font-size: 0.92rem;
    color: var(--ink);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 480px) {
    .kt-email-popover { right: -60px; width: 240px; }
 
    /* compact header so the full title fits next to the hamburger and bell */
    .kt-header { gap: 8px; padding-left: 12px; padding-right: 12px; }
    .kt-brand { gap: 8px; }
    .kt-brand-icon { width: 34px; height: 34px; }
    .kt-brand-title { font-size: 1.1rem; letter-spacing: 0; }
    .kt-brand-tagline { font-size: 0.6em; letter-spacing: 0; }
}

/* ---------- Footer ---------- */
.kt-footer {
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    padding: 16px;
    background: var(--cream-dark);
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
    .kt-menu-btn { display: flex; }
    .kt-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 40; /* above .kt-header (30) and .kt-sidebar-backdrop, so the open drawer's
                         own top content is never hidden underneath the sticky header */
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        padding-top: env(safe-area-inset-top, 0px);
        box-shadow: 4px 0 18px rgba(0,0,0,0.15);
    }
    .kt-sidebar.is-open { transform: translateX(0); }
    .kt-sidebar-backdrop.is-open { display: block; z-index: 35; } /* also above the header, so it dims the whole screen */
    .kt-poem-card { padding: 30px 22px; }
    .kt-poem-title { font-size: 1.5rem; }
    .kt-main { padding: 24px 14px 48px; }
}

/* ---------- Theming utility ---------- */
@media (prefers-color-scheme: dark) {
    /* Poetry reads best on a warm paper tone regardless of system theme, so we intentionally
       keep the light palette. Fixed background/colors above already declare explicit values. */
}
