/*
  Ferheng — "Monument" design system
  Inspired by Taq-e Bostan, the Sassanid rock-relief arch near Kermanshah —
  the historical heart of Kalhorî-speaking Kurdistan. Warm carved stone,
  gold-leaf and manuscript-rubrication red, Kufic display type.

  Shared by every page. Page-specific rules stay in that page's own
  <style> block; anything here is common chrome (nav, header, search,
  result cards, footer) so the whole site reads as one system.
*/

:root {
    /* Monument — light (limestone / carved stone in daylight) */
    --bg-color: #EAE2D2;
    --card-bg: #F5F0E4;
    --text-color: #2B2620;
    --primary-color: #7A5219;
    --accent-color: #9C6F22;
    --accent-color-strong: #7A5219;
    --subtext-color: #6B6153;
    --border-color: #D9CDAF;
    --box-bg: #E1D7C1;
    --danger-color: #A73B32;
    --success-color: #4F6B5C;
    --info-color: #5B7290;
}

[data-theme="dark"] {
    /* Monument — night (basalt stone, gold leaf catching lamplight) */
    --bg-color: #1E1B17;
    --card-bg: #262119;
    --text-color: #EDE6D8;
    --primary-color: #E0B563;
    --accent-color: #D2A052;
    --accent-color-strong: #E0B563;
    --subtext-color: #A79A82;
    --border-color: #3A3226;
    --box-bg: #2A2418;
    --danger-color: #D4695A;
    --success-color: #7A9C8C;
    --info-color: #7C93B3;
}

* { box-sizing: border-box; }

body {
    font-family: 'Noto Naskh Arabic', 'Vazirmatn', 'Source Sans 3', system-ui, sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(ellipse 900px 500px at 50% -10%, rgba(156, 111, 34, .10), transparent 60%),
        repeating-linear-gradient(0deg, rgba(43, 38, 32, .02) 0px, rgba(43, 38, 32, .02) 1px, transparent 1px, transparent 3px);
    color: var(--text-color);
    margin: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
    width: 100%;
    max-width: 800px;
    flex: 1;
}

/* Top Nav Responsive Layout */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.user-menu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9rem;
    font-family: 'Source Sans 3', system-ui, sans-serif;
}

.user-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
}

.lang-switcher {
    display: flex;
    gap: 4px;
    font-family: 'Source Sans 3', system-ui, sans-serif;
}

.lang-switcher a {
    text-decoration: none;
    color: var(--subtext-color);
    font-weight: bold;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--box-bg);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.lang-switcher a.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.theme-toggle-btn {
    background: var(--box-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn:hover { border-color: var(--accent-color); }

/* Header */
.header {
    text-align: center;
    margin-bottom: 28px;
    position: relative;
    padding-top: 6px;
}

.header img.logo {
    width: 140px;
    max-width: 40vw;
    height: auto;
    filter: drop-shadow(0 2px 10px rgba(156, 111, 34, .25));
}

.header h1 {
    font-family: 'Noto Kufi Arabic', 'Source Serif 4', serif;
    font-weight: 700;
    color: var(--primary-color);
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    margin: 12px 0 6px 0;
}

.header p {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    color: var(--subtext-color);
    font-size: clamp(0.9rem, 3vw, 1.05rem);
    margin: 0;
}

/* Search Container */
.search-container {
    position: relative;
    width: 100%;
    margin-bottom: 25px;
}

.search-box {
    display: flex;
    box-shadow: 0 4px 14px rgba(43, 38, 32, 0.08);
    border-radius: 10px;
    overflow: hidden;
    border: 1.5px solid var(--border-color);
    background: var(--card-bg);
}

.search-box:focus-within { border-color: var(--accent-color); }

.search-box input {
    flex: 1;
    padding: 14px 16px;
    font-size: 1rem;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-color);
    min-width: 0;
    font-family: inherit;
}

.search-box button {
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    padding: 0 22px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    font-family: 'Source Sans 3', system-ui, sans-serif;
    transition: background-color .15s ease;
}

.search-box button:hover { background-color: var(--accent-color-strong); }

.autocomplete-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(43, 38, 32, 0.15);
    z-index: 1000;
    display: none;
    border: 1px solid var(--border-color);
    max-height: 350px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover,
.suggestion-item.active { background: var(--box-bg); }
.suggestion-item.active { box-shadow: inset 3px 0 0 var(--accent-color); }
.sug-kalhori { font-family: 'Noto Kufi Arabic', serif; font-size: 1.1rem; font-weight: bold; color: var(--primary-color); }
.sug-trans { color: var(--subtext-color); font-size: 0.85rem; font-family: 'Source Sans 3', sans-serif; }
.suggestion-item mark {
    background: color-mix(in srgb, var(--accent-color) 35%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}

/* Result Cards */
.result-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: clamp(16px, 4vw, 28px);
    box-shadow: 0 4px 18px rgba(43, 38, 32, 0.07);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    position: relative;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.kalhori-title {
    font-family: 'Noto Kufi Arabic', 'Source Serif 4', serif;
    font-size: clamp(2rem, 6vw, 3rem);
    color: var(--primary-color);
    margin: 0;
    font-weight: 700;
    line-height: 1.1;
}

.latin-sub {
    font-family: 'IBM Plex Mono', 'Source Sans 3', monospace;
    direction: ltr;
    unicode-bidi: isolate;
    color: var(--subtext-color);
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    margin: 4px 0 16px 0;
    display: block;
}

.btn-suggest-edit {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--subtext-color);
    text-decoration: none;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    white-space: nowrap;
    background: var(--card-bg);
    font-family: 'Source Sans 3', sans-serif;
}

.btn-suggest-edit:hover { border-color: var(--accent-color); color: var(--accent-color-strong); }

.audio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--box-bg);
    color: var(--accent-color);
    cursor: pointer;
    font-size: 0.95rem;
    vertical-align: middle;
    transition: background-color .15s ease, transform .1s ease;
}
.audio-btn:hover { background: var(--accent-color); color: #fff; }
.audio-btn.playing {
    background: var(--accent-color);
    color: #fff;
    animation: audio-pulse 1s ease-in-out infinite;
}
@keyframes audio-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
    .audio-btn.playing { animation: none; }
}

.fav-toggle-btn { cursor: pointer; }
.fav-toggle-btn.is-fav {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}
.fav-toggle-btn.is-fav:hover { color: #fff; }
.fav-toggle-btn:disabled { opacity: 0.6; cursor: wait; }

.translations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.lang-label {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.75rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    margin-bottom: 4px;
}

.lang-value {
    font-size: clamp(1.1rem, 3.5vw, 1.35rem);
    font-weight: bold;
}

.definition-box {
    background: var(--box-bg);
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 0.95rem;
    line-height: 1.7;
    border: 1px solid var(--border-color);
}

.footer {
    width: 100%;
    text-align: center;
    padding: 22px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 30px;
    color: var(--subtext-color);
    font-size: 0.85rem;
    font-family: 'Source Sans 3', sans-serif;
}

/* Homepage extras: stats strip + Word of the Day */
#homeExtras { margin-bottom: 10px; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.stat {
    background: var(--card-bg);
    padding: 14px 10px;
    text-align: center;
}

.stat .n {
    display: block;
    font-family: 'Noto Kufi Arabic', 'Source Serif 4', serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.stat .l {
    display: block;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.7rem;
    color: var(--subtext-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 5px;
}

.wotd {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 20px;
}

.wotd-eyebrow {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-color);
    font-weight: 700;
    margin-bottom: 6px;
    display: block;
}

.medallion {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Kufi Arabic', serif;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.wotd .wtitle {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.wotd h3 {
    margin: 0;
    font-family: 'Noto Kufi Arabic', serif;
    font-size: clamp(1.3rem, 4vw, 1.7rem);
    color: var(--primary-color);
}

.wotd h3 a { color: inherit; text-decoration: none; }
.wotd h3 a:hover { text-decoration: underline; }

.wotd .translit {
    font-family: 'IBM Plex Mono', 'Source Sans 3', monospace;
    direction: ltr;
    unicode-bidi: isolate;
    color: var(--subtext-color);
    font-size: 0.95rem;
}

.wotd .meanings {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.85rem;
}

.wotd .meanings b {
    color: var(--accent-color);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    margin-inline-end: 4px;
}

.wotd .meanings span { color: var(--text-color); display: inline-flex; align-items: center; gap: 5px; }
.wotd .meanings .audio-btn,
.translations .audio-btn {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
}

/* Mobile Fine-Tuning */
@media (max-width: 600px) {
    .top-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .user-menu {
        justify-content: space-between;
    }
    .search-box button {
        padding: 0 14px;
    }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .wotd { grid-template-columns: 1fr; text-align: center; }
    .wotd .medallion { margin: 0 auto; }
    .wotd .wtitle, .wotd .meanings { justify-content: center; }
}
