/* ═══════════════════════════════════════════
   FKG Sözlük — Design System
   Apple-inspired matte white & gray
   ═══════════════════════════════════════════ */

:root {
    --bg: #F5F5F7;
    --surface: #FFFFFF;
    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.1);
    --text-1: #1D1D1F;
    --text-2: #86868B;
    --text-3: #AEAEB2;
    --accent: #0071E3;
    --accent-soft: rgba(0, 113, 227, 0.08);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 0 4px rgba(0, 113, 227, 0.12);

    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 9999px;

    --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 180ms;
    --t-normal: 350ms;
    --t-slow: 500ms;
}

/* ── Dark Mode Variables ── */
body.dark-mode {
    --bg: #121212;
    --surface: #1E1E1E;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    --text-1: #F5F5F7;
    --text-2: #A1A1A6;
    --text-3: #6E6E73;
    --accent-soft: rgba(10, 132, 255, 0.15);
}

body.dark-mode .main-header {
    background: rgba(18, 18, 18, 0.72);
}

body.dark-mode .sidebar {
    background: rgba(30, 30, 30, 0.88);
}

body.dark-mode .search-dropdown {
    background: rgba(30, 30, 30, 0.92);
}

body.dark-mode .select-apple {
    background-color: #2c2c2e;
}

body.dark-mode .loading-state .spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
}

body.dark-mode .more-overlay {
    background: rgba(30, 30, 30, 0.8);
    color: var(--accent);
}

body.dark-mode .play-icon {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.dark-mode .sidebar-link:hover,
body.dark-mode .recent-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .search-bar input {
    background-color: #2c2c2e;
}

body.dark-mode .hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ── Reset ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text-1);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

a:hover {
    color: #0077ED;
}

/* ── Header ── */
.main-header {
    background: rgba(245, 245, 247, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1002;
    padding: 14px 0;
}

.header-container {
    max-width: 100%;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.hamburger-container {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    z-index: 1002;
}

.header-theme-switch {
    display: flex;
    align-items: center;
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 44px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #D1D1D6;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

body.dark-mode .slider {
    background-color: #3A3A3C;
}

.slider:before {
    background-color: #fff;
    bottom: 3px;
    content: "";
    height: 18px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 18px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(19px);
}

.slider .sun-icon,
.slider .moon-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity var(--t-fast) var(--ease);
    color: #fff;
    z-index: 1;
}

.slider .sun-icon {
    right: 6px;
    opacity: 1;
}

.slider .moon-icon {
    left: 6px;
    opacity: 0;
}

input:checked+.slider .sun-icon {
    opacity: 0;
}

input:checked+.slider .moon-icon {
    opacity: 1;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--text-1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    transition: background var(--t-fast) var(--ease);
    position: relative;
    z-index: 1002;
}

.hamburger-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

body.dark-mode .hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.hamburger-icon {
    width: 20px;
    height: 14px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-1);
    border-radius: 2px;
    transition: all var(--t-normal) var(--ease-out);
    transform-origin: center;
}

body.sidebar-open .hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

body.sidebar-open .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

body.sidebar-open .hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}


.sidebar-link svg {
    margin-right: 12px;
    opacity: 0.7;
}

.sidebar-link:hover svg,
.sidebar-link.active svg {
    opacity: 1;
}

.recent-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.recent-title {
    font-size: 0.75rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    padding: 0 16px;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-item {
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--text-2);
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-1);
}

body.dark-mode .recent-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.empty-recent {
    font-size: 0.85rem;
    color: var(--text-3);
    padding: 0 16px;
    font-style: italic;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
}

.logo-img {
    height: 48px;
    width: auto;
    object-fit: contain;
    transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}

.logo:hover .logo-img {
    transform: scale(1.02);
    opacity: 0.95;
}

/* ── Search ── */
.search-container {
    flex: 0 1 560px;
    position: relative;
}

.search-bar {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
    transition: color var(--t-fast) var(--ease);
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 48px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text-1);
    transition: all var(--t-fast) var(--ease);
    box-shadow: var(--shadow-xs);
}

.search-bar input::placeholder {
    color: var(--text-3);
}

.search-bar input:focus {
    outline: none;
    border-color: rgba(0, 113, 227, 0.3);
    box-shadow: var(--shadow-glow);
}

.search-bar input:focus~.search-icon,
.search-bar:focus-within .search-icon {
    color: var(--accent);
}

/* ── Search Dropdown ── */
.search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    max-height: 380px;
    overflow-y: auto;
}

.search-dropdown.active {
    display: flex;
}

.search-dropdown-item {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
    color: var(--text-1);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.search-dropdown-item-icon {
    color: var(--text-3);
    flex-shrink: 0;
}

.search-dropdown-item-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.search-dropdown-item-title {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown-item-type {
    font-size: 0.7rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* ── Sidebar ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 998;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(200%) blur(30px);
    -webkit-backdrop-filter: saturate(200%) blur(30px);
    border-right: 1px solid var(--border);
    z-index: 1001;
    padding: 85px 20px 24px 20px;
    transition: left var(--t-normal) var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    color: var(--text-1);
    font-weight: 500;
    font-size: 1rem;
    padding: 11px 16px;
    border-radius: var(--r-sm);
    transition: all var(--t-fast) var(--ease);
    display: flex;
    align-items: center;
}

.sidebar-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-1);
}

.sidebar-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* ── Layout & Main Content ── */
.layout-wrapper {
    transition: padding-left var(--t-normal) var(--ease-out), transform var(--t-normal) var(--ease-out);
    width: 100%;
    padding-left: 0;
}

/* On desktop, the sidebar opening resizes the main screen area nicely */
@media (min-width: 769px) {
    body.sidebar-open .layout-wrapper {
        padding-left: 280px;
    }

    .sidebar-overlay {
        display: none !important;
        /* Allow interaction with the pushed page */
    }
}

/* On mobile, it's better to just slide over to prevent the screen from crushing to <100px width */
@media (max-width: 768px) {
    body.sidebar-open .layout-wrapper {
        transform: translateX(280px);
    }

    .sidebar-overlay.active {
        background-color: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(2px);
    }
}

main {
    padding: 48px 0 60px;
    min-height: calc(100vh - 140px);
}

.top-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 48px auto;
    gap: 24px;
    max-width: 1000px;
    width: 100%;
}

.page-title {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    text-align: center;
    color: var(--text-1);
}

/* ── Filters ── */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.select-apple {
    appearance: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 10px 38px 10px 18px;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-1);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23AEAEB2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    transition: all var(--t-fast) var(--ease);
    box-shadow: var(--shadow-xs);
}

.select-apple:hover {
    border-color: var(--border-strong);
}

.select-apple:focus {
    outline: none;
    border-color: rgba(0, 113, 227, 0.3);
    box-shadow: var(--shadow-glow);
}

.select-apple:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Result Cards ── */
.results-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.topic-card {
    width: 100%;
    background: var(--surface);
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    padding: 28px 32px;
    display: flex;
    gap: 32px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-normal) var(--ease-out),
        box-shadow var(--t-normal) var(--ease-out),
        border-color var(--t-normal) var(--ease);
    animation: fadeInUp var(--t-slow) var(--ease-out) backwards;
    cursor: pointer;
    position: relative;
}

/* Stagger animation delay via nth-child */
.topic-card:nth-child(1) {
    animation-delay: 0ms;
}

.topic-card:nth-child(2) {
    animation-delay: 80ms;
}

.topic-card:nth-child(3) {
    animation-delay: 160ms;
}

.topic-card:nth-child(4) {
    animation-delay: 240ms;
}

.topic-card:nth-child(5) {
    animation-delay: 320ms;
}

.topic-card:nth-child(n+6) {
    animation-delay: 400ms;
}

.topic-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.card-main {
    flex: 1.3;
    min-width: 220px;
}

.card-lesson {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    display: inline-block;
}

.card-title {
    font-size: 1.35rem;
    font-weight: 650;
    margin-bottom: 8px;
    color: var(--text-1);
    letter-spacing: -0.02em;
}

.card-title a {
    color: inherit;
}

.card-title a:hover {
    color: var(--accent);
}

.card-desc {
    color: var(--text-2);
    font-size: 0.9rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Card Sections ── */
.card-section {
    flex: 1;
    min-width: 180px;
    padding-left: 24px;
    border-left: 1px solid var(--border);
}

.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-3);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── Word List in Cards ── */
.word-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.word-item {
    font-size: 0.9rem;
    color: var(--text-1);
    padding: 7px 12px;
    background: var(--bg);
    border-radius: var(--r-sm);
    transition: all var(--t-fast) var(--ease);
    display: block;
}

.word-item:hover {
    background: rgba(0, 113, 227, 0.06);
    color: var(--accent);
}

.more-item {
    position: relative;
    overflow: hidden;
}

.more-item span,
.more-item .word-item {
    filter: blur(3px);
    opacity: 0.4;
}

.more-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    z-index: 2;
    border-radius: var(--r-sm);
}

/* ── Media Preview ── */
.media-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.media-thumbnail {
    aspect-ratio: 16/9;
    border-radius: var(--r-sm);
    background-color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: transform var(--t-fast) var(--ease);
}

.media-thumbnail:hover {
    transform: scale(1.03);
}

.media-thumbnail:hover .play-icon {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.play-icon {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast) var(--ease-out);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    color: var(--text-1);
}

/* ── Topic Detail Page ── */
.topic-header {
    text-align: center;
    margin-bottom: 56px;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.topic-header .card-lesson {
    font-size: 0.8rem;
}

.topic-header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin: 12px 0 20px;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text-1);
}

.topic-header p {
    font-size: 1.05rem;
    color: var(--text-2);
    line-height: 1.7;
}

.detail-section {
    margin-bottom: 56px;
}

.detail-section h2 {
    font-size: 1.3rem;
    font-weight: 650;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.01em;
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.word-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-fast) var(--ease-out),
        box-shadow var(--t-fast) var(--ease),
        border-color var(--t-fast) var(--ease);
}

.word-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.word-card h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 10px;
    font-weight: 600;
}

.word-card p {
    color: var(--text-2);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ── Full Media Grid ── */
.full-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-fast) var(--ease-out),
        box-shadow var(--t-fast) var(--ease);
}

.video-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.video-wrapper {
    aspect-ratio: 16/9;
    background-color: #1a1a1a;
    position: relative;
}

.video-wrapper iframe,
.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-info {
    padding: 16px 20px;
}

.video-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

/* ── Loading State ── */
.loading-state {
    text-align: center;
    padding: 80px 0;
    color: var(--text-3);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

/* ── Empty State ── */
.text-secondary,
.empty-state {
    color: var(--text-3);
    font-size: 0.9rem;
}

/* ── Animations ── */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 36px 0;
    color: var(--text-3);
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    letter-spacing: 0.01em;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .topic-card {
        flex-direction: column;
        gap: 20px;
        padding: 24px;
    }

    .card-section {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 16px;
    }
}

@media (max-width: 768px) {
    .header-container {
        gap: 12px;
        padding: 0 20px;
    }

    .hamburger-container {
        flex: 0 0 auto;
    }

    .search-container {
        flex: 1;
    }

    .logo {
        flex: 0 0 auto;
    }

    .page-title {
        font-size: 1.6rem;
    }

    .topic-header h1 {
        font-size: 2rem;
    }

    .filters {
        gap: 8px;
    }

    .select-apple {
        font-size: 0.82rem;
        padding: 8px 32px 8px 14px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .topic-card {
        padding: 20px;
    }

    .card-title {
        font-size: 1.15rem;
    }

    .search-bar input {
        font-size: 0.88rem;
        padding: 10px 16px 10px 42px;
    }
}