/* ==========================================================================
   duzgun.org Tech News — modern design system
   Light-first with an accent gradient; dark mode via [data-theme="dark"].
   ========================================================================== */

/* ---------- Design tokens -------------------------------------------------- */
:root {
    /* Accent */
    --accent-1: #6366f1;            /* indigo */
    --accent-2: #06b6d4;            /* cyan   */
    --gradient: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    --accent-soft: rgba(99, 102, 241, 0.12);
    --accent-ring: rgba(99, 102, 241, 0.35);

    /* Light surfaces */
    --bg: #f6f8fc;
    --bg-tint: #eef2fb;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.72);

    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Space Grotesk', var(--font-body);

    /* Shape & depth */
    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.12);
    --shadow-accent: 0 10px 30px rgba(99, 102, 241, 0.25);

    /* Motion & layout */
    --transition: 0.25s ease;
    --container: 1200px;

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0b1120;
    --bg-tint: #0e1628;
    --surface: #111827;
    --surface-2: #1e293b;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #1f2937;
    --glass: rgba(17, 24, 39, 0.72);
    --accent-soft: rgba(99, 102, 241, 0.18);
    --accent-ring: rgba(99, 102, 241, 0.5);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 10px 30px rgba(6, 182, 212, 0.25);

    color-scheme: dark;
}

/* ---------- Base ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--accent-1); text-decoration: none; }

img { max-width: 100%; display: block; }

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

main.container { flex: 1; }

/* ---------- Header --------------------------------------------------------- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 0.85rem 0;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.nav-links ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

.nav-links a {
    position: relative;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.15rem;
    height: 2px;
    border-radius: 2px;
    background: var(--gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition);
}

.nav-links a:hover { color: var(--accent-1); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }
.nav-links a.active { color: var(--accent-1); }

/* Settings cluster: selectors + theme toggle */
.selectors-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.timezone-wrapper, .language-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.timezone-label, .language-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
}

#timezone-options, #language-select {
    padding: 0.35rem 1.6rem 0.35rem 0.6rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-width: 6rem;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.75rem;
}

#timezone-options:focus, #language-select:focus {
    outline: none;
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

#current-timezone { display: none; }

/* Theme toggle */
#theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

#theme-toggle:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
    transform: translateY(-1px);
}

#theme-toggle svg { width: 20px; height: 20px; }
#theme-toggle .icon-sun { display: none; }
#theme-toggle .icon-moon { display: block; }
[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ---------- Hero ----------------------------------------------------------- */
#hero {
    position: relative;
    text-align: center;
    padding: clamp(1.5rem, 3.6vw, 2.7rem) 1rem;
    margin: 1.5rem 0 1rem;
    border-radius: var(--radius);
    background:
        radial-gradient(120% 140% at 50% 0%, var(--accent-soft), transparent 60%),
        var(--bg-tint);
    border: 1px solid var(--border);
    overflow: hidden;
}

.hero-container { max-width: 760px; margin: 0 auto; }

#hero h2 {
    margin: 0 0 0.6rem;
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 4.5vw, 2.9rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#hero p {
    margin: 0 auto;
    max-width: 620px;
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    color: var(--muted);
}

/* ---------- Articles ------------------------------------------------------- */
#articles { margin-bottom: 1.5rem; }

.articles-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 1.25rem 0;
}

.article {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.article:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-ring);
}

.article-content { display: flex; flex-direction: column; height: 100%; }

.article-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.article:hover .article-image img { transform: scale(1.06); }

.placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.85rem;
    background: var(--surface-2);
}

.placeholder-img::before { content: "No Image"; }

.article-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 1.1rem 1.15rem 1.15rem;
}

.article h3 {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article h3 a { color: var(--text); transition: color var(--transition); }
.article h3 a:hover { color: var(--accent-1); }

.article .date {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.article .source {
    align-self: flex-start;
    margin: auto 0 0;
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-1);
    background: var(--accent-soft);
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.article .source::before { content: "📰"; font-size: 0.85rem; }

/* ---------- Skeleton loaders ----------------------------------------------- */
.skeleton {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.skeleton .sk-img { aspect-ratio: 16 / 9; }
.skeleton .sk-body { padding: 1.1rem 1.15rem; display: flex; flex-direction: column; gap: 0.6rem; }
.skeleton .sk-line { height: 0.85rem; border-radius: 6px; }
.skeleton .sk-line.short { width: 55%; }
.skeleton .sk-line.pill { width: 35%; height: 1.4rem; border-radius: var(--radius-pill); margin-top: 0.4rem; }

.sk-img, .sk-line {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

#loading-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--muted);
}

/* ---------- Pagination ----------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.top-pagination { margin-bottom: 1.25rem; }
.bottom-pagination { margin-top: 1.5rem; padding-top: 1.25rem; padding-bottom: 1.5rem; border-top: 1px solid var(--border); }

.pagination-btn {
    background: var(--gradient);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-accent);
}

.pagination-btn:disabled,
.pagination-btn.disabled {
    background: var(--surface-2);
    color: var(--muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.page-controls { display: flex; align-items: center; gap: 0.75rem; margin: 0 0.5rem; }
.page-indicator { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.page-selector { display: flex; align-items: center; gap: 0.4rem; }

.page-selector input {
    width: 60px;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}

.page-selector input:focus {
    outline: none;
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ---------- Cards / panels (about, contact) -------------------------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    margin: 2rem auto;
    box-shadow: var(--shadow);
}

.about-container { max-width: 800px; }
.contact-container { max-width: 900px; }

.panel h2 {
    margin-top: 0;
    font-family: var(--font-display);
    color: var(--text);
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.panel p { color: var(--text); margin-bottom: 1rem; }

.btn-gradient {
    display: inline-block;
    background: var(--gradient);
    color: #fff;
    padding: 0.65rem 1.4rem;
    border: none;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn-gradient:hover { transform: translateY(-2px); box-shadow: var(--shadow-accent); }

.back-button { margin-top: 1.5rem; }

/* Contact form */
.contact-form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: 600; font-size: 0.9rem; color: var(--text); }

.form-group input,
.form-group textarea {
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-group textarea { min-height: 200px; resize: vertical; }
.submit-btn { align-self: flex-start; }

/* ---------- Footer --------------------------------------------------------- */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--muted);
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
    font-size: 0.9rem;
}

/* ---------- Overlays (translation popup / errors) -------------------------- */
.translation-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--gradient);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    animation: fadeIn 0.3s ease-out;
}

.translation-error-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #e74c3c;
    color: #fff;
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    text-align: center;
    font-size: 0.9rem;
    max-width: 90%;
    animation: fadeIn 0.3s ease-out, fadeOut 0.3s ease-in 4.7s;
}

.translation-popup .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ---------- Home: fit within the viewport (desktop) ------------------------ */
/* Lock the home page to the viewport height and let only the article grid
   scroll, so the header, hero, pagination, and footer are always visible
   without scrolling the whole page. Other pages flow normally. */
@media (min-width: 769px) {
    body.home {
        height: 100vh;        /* fallback */
        height: 100dvh;
        overflow: hidden;
    }

    body.home main.container {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    body.home #hero { flex: none; margin: 1rem 0 0.75rem; }

    body.home #articles {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        margin-bottom: 0;
    }

    body.home .top-pagination,
    body.home .bottom-pagination { flex: none; }

    body.home .articles-container {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        margin: 0.75rem 0;
        padding-right: 4px; /* room for the scrollbar */
    }
}

/* ---------- Responsive ----------------------------------------------------- */
@media (max-width: 768px) {
    .container { padding: 0 16px; }

    header nav { flex-direction: column; align-items: center; gap: 0.75rem; }
    .nav-right { flex-direction: column; gap: 0.6rem; }
    .nav-links ul { justify-content: center; flex-wrap: wrap; }
    .selectors-row { justify-content: center; }

    .page-controls { flex-direction: column; gap: 0.5rem; }

    /* Comfortable touch targets */
    .pagination-btn, #timezone-options, #language-select { min-height: 38px; }
}

@media (max-width: 480px) {
    .articles-container { grid-template-columns: 1fr; }
    .pagination-btn { padding: 0.45rem 0.7rem; font-size: 0.8rem; }
    .timezone-label span, .language-label span { display: none; }
    .timezone-label { display: none; }
    .language-label {
        color: transparent;
        position: relative;
        display: inline-block;
        width: 1.6em;
    }
    .language-label::after {
        color: var(--muted);
        position: absolute;
        left: 0;
        top: 0;
        content: attr(data-lang);
    }
}

/* ---------- Reduced motion -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .article:hover { transform: none; }
}
