/* Cross-page polish: iPhone input zoom, floating theme button, song numerals, brand logo. */

/* Song numbers: serif old-style digits made "161h" look corrupted — use lining, fixed-width figures. */
.song-num, .related-number, .song-number, .song-number-badge, .result-number {
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum" 1, "tnum" 1;
}

/* Brand mark image inside the header emblem / auth-card logo. */
.logo-emblem:has(img) { background: none; border: 0; border-radius: 22%; overflow: hidden; padding: 0; }
.logo-emblem img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 22%; }
img.logo-icon { background: none !important; border-radius: 22% !important; object-fit: cover; display: block; }

@media (max-width: 768px) {
    /* iOS Safari zooms the page when a focused field is under 16px. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select, textarea { font-size: 16px !important; }
}

/* Password show/hide */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3.25rem !important; }
.pw-toggle { position: absolute; top: 0; right: 0; bottom: 0; width: 3rem; display: flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--text-light); cursor: pointer; border-radius: 0 10px 10px 0; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--text-dark); }

/* Balanced line breaks for headings and taglines (no lonely last word). */
.hero h2, .hero p, .section-heading h2, .page-title h2, .page-title p { text-wrap: balance; }
.hero p { line-height: 1.45; }

@media (max-width: 768px) {
    /* Header nav: tidy 2-column grid of equal buttons instead of ragged wrapping. */
    header nav { width: 100%; }
    header .nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; width: 100%; }
    header .nav-links li { display: block; }
    header .nav-links li:only-child { grid-column: 1 / -1; }
    header .nav-links .nav-btn { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 0.5rem; }
    header .nav-links .user-info { grid-column: 1 / -1; text-align: center; padding: 0.25rem 0; }
}

.section-heading h2 { line-height: 1.3; }

/* Terms / Privacy pages and footer links */
.legal { max-width: 820px; margin: 0 auto; padding: 2rem 0 1rem; }
.legal-title { font-family: 'EB Garamond', 'Power Geez Unicode1', 'Noto Sans Ethiopic', serif; font-size: 2rem; line-height: 1.3; text-align: center; text-wrap: balance; }
.legal-title span { display: block; font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 0.8em; color: var(--text-mid); }
.legal-updated { text-align: center; color: var(--text-light); font-style: italic; margin: 0.4rem 0 1.75rem; }
.legal-card { padding: 1.5rem 1.75rem; margin-bottom: 1.25rem; }
.legal-card h3 { font-family: 'EB Garamond', 'Power Geez Unicode1', 'Noto Sans Ethiopic', serif; font-size: 1.2rem; line-height: 1.4; margin-bottom: 0.75rem; }
.legal-card h3 span { font-family: 'Cormorant Garamond', serif; font-weight: 600; color: var(--text-mid); }
.legal-card p { margin-bottom: 0.75rem; line-height: 1.75; }
.legal-card p.en, .legal-card ul.en { color: var(--text-mid); font-size: 1.02rem; }
.legal-card ul { margin: 0 0 0.9rem 1.25rem; line-height: 1.7; }
.legal-card li { margin-bottom: 0.3rem; }
.legal-card a { color: var(--accent); }
.legal-links a { color: var(--text-mid); text-decoration: none; padding: 0.35rem 0.25rem; }
.legal-links a:hover { text-decoration: underline; }
@media (max-width: 768px) {
    .legal { padding-top: 1.25rem; }
    .legal-title { font-size: 1.6rem; }
    .legal-card { padding: 1.1rem 1.1rem; }
}

/* ── Song page on phones ── */
@media (max-width: 768px) {
    html body .container { max-width: 100% !important; width: 100% !important; padding: 0 16px; }
    html body .header-content { max-width: 100%; padding: 0 16px; gap: 0.75rem; }
    html body .song-container { padding: 1.25rem 1.1rem; }
    html body .song-container .song-title { font-size: 1.75rem; }
    html body .song-container .song-meta { gap: 0.4rem 1.25rem; }
    /* Action buttons: zoom + singing mode full width, the rest in pairs. */
    html body .action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; flex-direction: initial; }
    html body .action-buttons .zoom-controls,
    html body .action-buttons #tpToggleBtn { grid-column: 1 / -1; }
    html body .action-buttons .btn { justify-content: center; min-height: 44px; padding: 0.6rem 0.75rem; }
    .zoom-controls { justify-content: center; }
    html body .zoom-btn { width: 44px; height: 44px; }
}

/* Related songs: number then title, left-aligned. */
.related-song-item { justify-content: flex-start !important; gap: 0.9rem; min-height: 44px; }
.related-number { min-width: 3.2rem; text-align: left; }
.related-title { text-align: left; }

/* ── Amharic index: keep the current letter in view; tidy floating buttons; bigger tap rows ── */
.fidel-letter-header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 0.4rem 0; margin-bottom: 0.5rem; }
@media (max-width: 768px) {
    .song-link { min-height: 44px; align-items: center !important; padding: 0.5rem 0.6rem !important; }
    html .back-top { right: 0.75rem; bottom: calc(4rem + env(safe-area-inset-bottom, 0px)); width: 40px; height: 40px; }
}

@media (max-width: 768px) {
    html body .back-link { white-space: nowrap; padding: 0.5rem 0.75rem; font-size: 0.92rem; }
    html body .back-link span { white-space: nowrap; }
}

/* ── Minimum 44px touch targets (found by audit) ── */
.back-home a { min-height: 44px; }
.remember-group { min-height: 44px; }
.remember-group label { cursor: pointer; }
@media (max-width: 768px) {
    html body .toolbar-btn { min-height: 44px; }
    /* Amharic index letter jump: 6 equal columns, 44px tall cells */
    html body .fidel-nav-links { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.25rem; }
    html body .fidel-nav-links a { width: auto; height: 44px; }
}

/* ── Account / admin pages (users list, change password) ── */
.app-wrap { max-width: 820px; margin: 0 auto; padding: 2rem 0 1rem; }
.app-narrow { max-width: 520px; }
.app-title { font-family: 'EB Garamond', 'Power Geez Unicode1', 'Noto Sans Ethiopic', serif; font-size: 1.9rem; text-align: center; line-height: 1.3; margin-bottom: 1.25rem; text-wrap: balance; }
.app-title span { display: block; font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 0.75em; color: var(--text-mid); }
.app-card { padding: 1.5rem 1.5rem 1.75rem; }
.app-form label { display: block; font-weight: 600; margin: 1rem 0 0.4rem; }
.app-form label:first-of-type { margin-top: 0; }
.app-form input { width: 100%; padding: 0.9rem 1rem; border: none; border-radius: var(--radius-sm); font-size: 1rem; background: var(--bg-light); color: var(--text-dark);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light); font-family: inherit; }
.app-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.app-btn { width: 100%; min-height: 48px; margin-top: 1.25rem; padding: 0.8rem 1rem; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 1.05rem; font-weight: 600; font-family: inherit;
    color: var(--text-on-accent); background: linear-gradient(145deg, var(--accent), var(--accent-dark)); }
.app-btn:hover { filter: brightness(1.12); }
.app-hint { font-size: 0.92rem; color: var(--text-light); margin-top: 0.4rem; line-height: 1.5; }
.app-alert { padding: 1rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; line-height: 1.5; }
.app-alert p { margin-top: 0.4rem; }
.app-alert-error { background: #f8d7da; color: #721c24; }
.app-alert-success { background: #d4edda; color: #155724; }
.temp-pass { display: inline-block; padding: 0.55rem 0.9rem; font-size: 1.35rem; letter-spacing: 1.5px; font-family: ui-monospace, Menlo, monospace; background: #fff; color: #111; border-radius: 8px; user-select: all; word-break: break-all; }
.user-row { padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.user-main h3 { font-family: 'EB Garamond', 'Power Geez Unicode1', 'Noto Sans Ethiopic', serif; font-size: 1.15rem; line-height: 1.35; }
.user-sub { color: var(--text-mid); font-size: 0.95rem; line-height: 1.55; word-break: break-word; }
.role-badge { display: inline-block; padding: 0.05rem 0.6rem; border-radius: 999px; font-size: 0.85rem; background: var(--bg-dark); color: var(--text-dark); }
.role-admin { background: var(--accent); color: var(--text-on-accent); }
.role-off { background: #f8d7da; color: #721c24; }
.user-actions { margin-top: 0.75rem; }
.user-actions summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; list-style: none; }
.user-actions summary::-webkit-details-marker { display: none; }
.user-actions form { margin-top: 0.75rem; }
/* tap the signed-in name to change your password */
.user-info a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.user-info a:hover { text-decoration: underline; }
@media (max-width: 768px) { .app-title { font-size: 1.6rem; } .app-card { padding: 1.1rem; } }

/* ── Song number badge (circle before the title) ── */
.song-title-row { display: flex; align-items: flex-start; gap: 0.9rem; margin-bottom: 0.5rem; }
.song-title-col { flex: 1; min-width: 0; }   /* Amharic and English titles share one left edge, beside the badge */
.song-title-row .song-title { margin-bottom: 0.15rem; }
.song-title-row .song-title-english { margin-bottom: 0; }
.song-title-row .song-badge { margin-top: 0.1rem; }
.song-badge { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-width: 3.2rem; height: 3.2rem; padding: 0 0.4rem; border-radius: 999px;
    background: var(--accent); color: var(--text-on-accent); font-size: 0.98rem; font-weight: 700; letter-spacing: 0.2px; font-variant-numeric: lining-nums tabular-nums;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light); }

/* ── Related songs accordion ── */
.related-group { margin-bottom: 0.9rem; border-radius: var(--radius-sm); background: var(--bg); box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light); }
.related-group summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 52px; padding: 0.6rem 1rem; cursor: pointer; list-style: none;
    font-family: 'EB Garamond', 'Power Geez Unicode1', 'Noto Sans Ethiopic', serif; font-size: 1.05rem; font-weight: 600; color: var(--text-dark); }
.related-group summary::-webkit-details-marker { display: none; }
.related-group summary small { font-weight: 400; color: var(--text-light); }
.rg-icon { flex: 0 0 auto; position: relative; width: 1.9rem; height: 1.9rem; border-radius: 50%;
    background: var(--accent); color: var(--text-on-accent); }
/* + and − are drawn as bars, not font glyphs, so they sit exactly in the middle of the circle. */
.rg-icon::before, .rg-icon::after { content: ''; position: absolute; left: 50%; top: 50%; background: currentColor; border-radius: 1px; transform: translate(-50%, -50%); }
.rg-icon::before { width: 0.85rem; height: 2px; }
.rg-icon::after { width: 2px; height: 0.85rem; }
.related-group[open] .rg-icon::after { display: none; }
.related-group .related-songs-list { padding: 0 0.75rem 0.9rem; gap: 0.5rem; }
.related-group .related-song-item { box-shadow: none; background: var(--bg-light); }
.related-group .related-song-item:hover { background: var(--bg-dark); box-shadow: none; }
.related-more, .related-more-note { display: block; text-align: center; padding: 0.6rem; color: var(--accent); font-weight: 600; text-decoration: none; min-height: 44px; }
.related-more-note { color: var(--text-light); font-weight: 400; font-style: italic; }

/* Header: one raised bar. Logo on the left, account links flat on the right. */
header .header-inner {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 0.6rem 1.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
}
header .logo { grid-column: 1; padding: 0; background: none; box-shadow: none; }
header .logo-emblem { box-shadow: none; }
header nav { grid-column: 2; justify-self: end; }
header .nav-btn { background: none; box-shadow: none; padding: 0.5rem 0.6rem; white-space: nowrap; }
header .nav-links { flex-wrap: nowrap; }
header .nav-btn:hover { box-shadow: none; text-decoration: underline; }
@media (max-width: 1024px) {
    /* Tablets: keep the logo on one line even when the account links are many. */
    header .header-inner { padding: 0.6rem 1.25rem; }
    header .logo-text h1 { white-space: nowrap; font-size: 1.3rem; }
    header .logo-text p { white-space: nowrap; font-size: 0.78rem; }
    header .nav-btn { padding: 0.5rem 0.4rem; font-size: 0.9rem; }
    header .nav-links { gap: 0.2rem; }
    .theme-fab-header .theme-fab-btn { width: 40px; height: 40px; }
}
@media (max-width: 768px) {
    /* Phones: logo left, account links right on one row; they wrap below only if there are many. */
    header .header-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem 0.5rem; padding: 0.6rem 0.75rem; }
    header .logo { gap: 10px; }
    header .logo-emblem, header .logo-emblem img { width: 44px; height: 44px; }
    header .logo-text h1 { font-size: 1.2rem; }
    header .logo-text p { font-size: 0.75rem; }
    header nav { width: auto; flex: 1 1 auto; justify-self: auto; }
    header .nav-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.1rem; width: auto; }
    header .nav-links .nav-btn { min-height: 44px; padding: 0.5rem 0.6rem; }
    header .nav-links .user-info { grid-column: auto; padding: 0; }
}

/* Song page: centre the lyrics as one block so short hymn lines don't hug the left edge.
   The block is as wide as its longest line (never wider than the card). */
.song-content:not(.tp-mode) { width: fit-content; min-width: min(100%, 22rem); max-width: 100%; margin-left: auto; margin-right: auto; }

/* Sticky footer: short pages keep the footer at the bottom instead of leaving empty space below it. */
body { display: flex; flex-direction: column; }
body > header, body > main, body > footer { width: 100%; }
body > main { flex: 1 0 auto; }
body > footer { margin-top: auto; }
body > .container { width: 100%; }

/* Song page, large screens: title block and lyrics share one left edge, set in from the card edge.
   Phones and tablets keep the centred lyrics block above. */
@media (min-width: 1025px) {
    .song-header > * { margin-left: 17%; }
    .song-content:not(.tp-mode) { margin-left: 17%; margin-right: auto; }
}
