/* ===== AIdemica — Common Styles (v2 · refreshed visual identity) ===== */

/* Fonts (Fraunces / Inter / JetBrains Mono / Manrope) are loaded directly
   in <head> of each HTML via <link rel="stylesheet"> to avoid the
   @import-in-CSS waterfall (which forces the browser to fetch this CSS,
   parse it, then start a second request for the fonts). */

:root {
    /* ─── Palette (matched to mascot — emerald robot, cream surfaces, soft sage) ─── */
    --primary:        #0F3D2E;      /* deep emerald — text/headings on light bg */
    --primary-dark:   #0A2A20;
    --accent:         #10B981;      /* deep emerald — primary brand (was acid teal #2DD4BF) */
    --accent-2:       #059669;      /* deeper for hover/active */
    --accent-3:       #047857;      /* deepest, for pressed */
    --accent-mint:    #6EE7B7;      /* soft mint for chip borders / decorative */
    --accent-soft:    #ECFDF5;      /* surface tint */
    --sage:           #C7E8DA;      /* secondary accent */
    --cream:          #FAF6EE;      /* warm bg from hero illustration */
    --cream-2:        #F0EAD8;      /* darker cream for borders/dividers on cream surfaces */

    --text:           #1A2833;      /* near-black, slight warm cool */
    --text-2:         #475569;      /* secondary text */
    --text-light:     #94A3B8;      /* tertiary / muted */
    --ink:            #0A2A20;      /* deepest emerald-black for dark sections / CTAs */

    --bg:             #FAFBFC;      /* page bg */
    --bg-light:       #FFFFFF;
    --bg-warm:        var(--cream);
    --surface:        #FFFFFF;
    --border:         #E8ECEF;
    --border-strong:  #D1D9E0;

    --danger:         #E11D48;
    --warn:           #F59E0B;
    --info:           #3B82F6;
    --success:        var(--accent-2);

    --radius:         12px;          /* updated from 8 → 12, more friendly */
    --radius-lg:      18px;
    --radius-pill:    99px;

    --shadow-xs:      0 1px 2px rgba(15, 61, 46, 0.04);
    --shadow-sm:      0 2px 8px rgba(15, 61, 46, 0.06);
    --shadow:         0 6px 24px rgba(15, 61, 46, 0.08);
    --shadow-lg:      0 24px 64px rgba(15, 61, 46, 0.12);
    --shadow-glow:    0 0 0 4px rgba(45, 212, 191, 0.18);

    --easing:         cubic-bezier(0.32, 0.72, 0, 1);
    --transition:     all 0.18s var(--easing);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
    line-height: 1.55;
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02','cv03','cv04','cv11';
}
h1, h2, h3, h4, h5, h6 {
    font-family: 'Manrope', 'Inter', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--primary);
    line-height: 1.2;
}
h1 { font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(1.5rem, 2.5vw, 2.25rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }

a { text-decoration: none; color: inherit; transition: var(--transition); }
img { max-width: 100%; height: auto; display: block; }
::selection { background: var(--accent); color: #fff; }

/* ─── Buttons (refreshed) ─── */
.btn {
    padding: 11px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(45, 212, 191, 0.35);
}
.btn-accent:hover {
    box-shadow: 0 6px 20px rgba(45, 212, 191, 0.5);
    transform: translateY(-1px);
}
.btn-outline {
    border: 1.5px solid var(--border-strong);
    color: var(--primary);
    background: var(--surface);
}
.btn-outline:hover {
    border-color: var(--primary);
    background: var(--accent-soft);
}
.btn-ghost { background: none; border: none; color: var(--text-2); cursor: pointer; padding: 8px 14px; }
.btn-ghost:hover { color: var(--accent-2); background: var(--accent-soft); }
.btn-lg { padding: 14px 32px; font-size: 15px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-pill { border-radius: var(--radius-pill); }

/* ─── Tags / Pills ─── */
.tag {
    font-size: 11px; padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600; display: inline-flex; align-items: center; gap: 5px;
    letter-spacing: 0.01em;
}
.tag-work { color: #1E40AF; background: #DBEAFE; }
.tag-wait { color: #B45309; background: #FEF3C7; }
.tag-done { color: var(--accent-2); background: var(--accent-soft); }
.tag-new  { color: #6D28D9; background: #EDE9FE; }
.tag-live::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
    box-shadow: 0 0 0 0 currentColor; animation: tagPulse 2s infinite;
}
@keyframes tagPulse {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    50%      { box-shadow: 0 0 0 6px transparent; opacity: 0.6; }
}

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 12.5px; font-weight: 600;
    margin-bottom: 6px; color: var(--text); letter-spacing: 0.01em;
}
/* Placeholder color for <select> — only the closed state when value="" looks faded.
   Options inside the open dropdown stay normal text colour. */
.form-group select:invalid { color: var(--text-light); }
.form-group select option { color: var(--text); }
.form-group select option[value=""] { color: var(--text-light); }
/* Required field marker (red asterisk) */
.form-group label.req::after {
    content: ' *'; color: var(--danger);
    font-weight: 700; margin-left: 2px;
}
/* Optional field hint (greyed inline note) */
.form-group label .opt {
    font-weight: 400; color: var(--text-light); font-size: 11px;
    font-family: 'JetBrains Mono', monospace; margin-left: 4px;
}
.form-group select,
.form-group input,
.form-group textarea {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 14px; font-family: inherit;
    outline: none; transition: var(--transition); background: var(--surface);
    color: var(--text);
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.form-group textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-light); }

/* ─── Upload ─── */
.upload-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 28px 20px; text-align: center; cursor: pointer;
    transition: var(--transition); color: var(--text-2);
    background: var(--bg);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent); background: var(--accent-soft);
    color: var(--accent-2);
}
.upload-zone i { font-size: 28px; color: var(--accent-2); margin-bottom: 8px; display: block; }
.uploaded-file {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--bg); border-radius: 8px; font-size: 13px; margin-top: 6px;
    border: 1px solid var(--border);
}
.uploaded-file .remove { margin-left: auto; color: var(--danger); cursor: pointer; font-size: 16px; transition: var(--transition); }
.uploaded-file .remove:hover { color: var(--text); }

/* ─── Modal ─── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15, 61, 46, 0.45); z-index: 1000;
    justify-content: center; align-items: center;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.18s var(--easing);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg);
    width: 540px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); animation: modalIn 0.22s var(--easing);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 18px; margin: 0; }
.modal-close {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--text-light); line-height: 1; transition: var(--transition);
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }

/* ─── File links ─── */
.file-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 6px; font-size: 13px; cursor: pointer;
    transition: var(--transition); background: #fff;
    min-width: 0;            /* allow flex children to shrink */
    overflow: hidden;
}
.file-link:hover { background: var(--bg); border-color: var(--border-strong); }
.file-link.ready { border-color: var(--border); }
.file-link:hover.ready { border-color: var(--primary); }
.file-link > i:first-child,
.file-link > .file-icon {
    flex-shrink: 0; color: var(--primary);
    width: 30px; height: 30px; border-radius: 7px;
    background: rgba(15,61,46,.06);
    display: grid; place-items: center;
}
.file-link > .file-icon svg,
.file-link > i:first-child svg { width: 16px; height: 16px; stroke-width: 1.75; }
.file-link .dl { width: 16px; height: 16px; }
.file-link .dl svg { width: 16px; height: 16px; stroke-width: 1.75; }
.file-link .fname,
.file-link > span:not(.dl),
.file-link > div {
    flex: 1; min-width: 0;
    color: var(--text); font-weight: 500;
}
.file-link > div { display: flex; flex-direction: column; gap: 2px; }
.file-link > div > strong,
.file-link .fname {
    display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 12.5px; font-weight: 600; color: var(--text);
}
.file-link > div > div { font-size: 11px; color: var(--text-light) !important; font-family: 'JetBrains Mono', monospace; }
.file-link .fmeta { font-size: 11px; color: var(--text-light); flex-shrink: 0; }
.file-link .dl { margin-left: auto; color: var(--text-light); transition: var(--transition); flex-shrink: 0; }
.file-link:hover .dl { color: var(--primary); }
.file-link.locked { opacity: 0.45; cursor: default; }

/* ─── Logo (used in navbar/header on every page) ─── */
.logo {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;            /* 700 not 800 — less aggressive shapes, "I" reads as "I" */
    letter-spacing: 0.01em;      /* tiny positive tracking to separate "AI" from "demica" */
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    color: var(--primary);
}
.logo .logo-mascot {
    width: 36px; height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 5px rgba(45, 212, 191, 0.25));
}
.logo i.fa-graduation-cap { display: none; }   /* hide old fallback icon if mascot present */

/* Wordmark — split "AI" + "demica" with color so they don't merge to "Al" visually */
.logo-text { display: inline-flex; align-items: baseline; }
.logo-ai {
    color: var(--accent);
    font-weight: 800;
    margin-right: 1px;
}
.header .logo-ai, .left-panel .logo-ai { color: var(--accent); }

/* ─── Mascot helper class (use anywhere as <img class="mascot-avatar"> ) ─── */
.mascot-avatar {
    width: 40px; height: 40px; border-radius: 50%; object-fit: contain;
    background: var(--accent-soft); padding: 4px; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(45, 212, 191, 0.25);
}
.mascot-sm { width: 28px; height: 28px; padding: 2px; }
.mascot-lg { width: 64px; height: 64px; padding: 6px; }

/* ─── Utility: subtle dotted background pattern (bg cream pages) ─── */
.bg-dotted {
    background-image:
        radial-gradient(rgba(15, 61, 46, 0.06) 1px, transparent 1px);
    background-size: 22px 22px;
}

/* ─── Scrollbars (subtle) ─── */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ─── Language switcher (unified, used on landing/login/dashboard) ─── */
.lang-wrap { position: relative; display: inline-flex; }
.lang-switch {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 10px; border-radius: 8px; cursor: pointer;
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    background: transparent; border: 1px solid var(--border);
    transition: var(--transition); font-family: 'JetBrains Mono', monospace;
}
.lang-switch:hover { border-color: var(--primary); color: var(--primary); }
.lang-switch i { font-size: 10px; opacity: 0.6; margin-left: 2px; }

.lang-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,.12); padding: 4px; min-width: 170px;
    display: none; z-index: 200;
}
.lang-menu.on { display: block; animation: langFade .15s ease both; }
@keyframes langFade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.lang-menu button {
    display: block; width: 100%; text-align: left; padding: 9px 12px;
    background: none; border: none; cursor: pointer; font-size: 13px;
    color: var(--text); border-radius: 7px; font-family: inherit; transition: .1s;
    font-weight: 500;
}
.lang-menu button:hover { background: rgba(16,185,129,.1); color: var(--primary); }

/* ─── CLS protection (15.05) ────────────────────────────────────────────
   Reserve space for late-arriving elements so Cumulative Layout Shift
   stays near 0 on first paint. Targets the worst offenders measured via
   Cloudflare RUM: /dashboard.html P75 0.933 and /login.html P75 0.867. */

/* Font Awesome icons load via external CDN — collapse to zero before
   webfont arrives. Reserve a minimum box so neighbors don't reflow. */
.fa-solid, .fa-regular, .fa-brands, .fab, .fas, .far, .fa,
[class*=" fa-"], [class^="fa-"] {
    display: inline-block;
    min-width: 1em;
    min-height: 1em;
    line-height: 1;
    text-align: center;
}

/* Images without intrinsic dimensions — once src loads they push siblings
   down. We can't add width/height to every <img> so use aspect-ratio
   inheritance as a soft fallback. */
img:not([width]):not([height]) {
    max-width: 100%;
    height: auto;
}

/* Empty data-i18n elements reserve at least one text-line of height so
   the page doesn't jump when locale JSON arrives. Use ::before with a
   zero-width space — this reserves line-height of vertical space without
   forcing any display:inline-block on block-level <h1>/<p> tags
   (which would shrink them off full-width and break layout). */
[data-i18n]:empty::before {
    content: "\200B";
}

/* Lang switcher dropdown sits above content; opening it must not push
   layout. position:absolute is already set, but reserve button width
   to avoid visible width pulse on first font load. */
.lang-switch, .lang-btn { min-width: 60px; }

/* ═══════════ DEMOS GRID — Приклади робіт section ═══════════
   13 cards: 4 referat + 4 kursova + 4 kreslennya + 1 preza.
   Previews lazy-load; cache 30d via Caddy /assets/* rule. */
.demos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    max-width: 1200px;
    margin: 24px auto 0;
    padding: 0 16px;
}
.demo-card {
    background: var(--surface, #fff);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(15, 61, 46, 0.08);
    display: flex;
    flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}
.demo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 61, 46, 0.10);
}
.demo-thumb {
    position: relative;
    display: block;
    aspect-ratio: 1200 / 1000; /* generic; img has own w/h */
    overflow: hidden;
    background: linear-gradient(135deg, #f7f5f0 0%, #efece4 100%);
}
.demo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}
.demo-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 61, 46, 0.92);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 999px;
}
.demo-meta {
    padding: 14px 16px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.demo-type {
    font-size: 10.5px;
    color: var(--accent2, #7B6F4D);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.demo-topic {
    margin: 0;
    font-size: 15px;
    line-height: 1.35;
    font-weight: 600;
    color: var(--primary, #0F3D2E);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.demo-stats {
    margin-top: auto;
    font-size: 11.5px;
    color: var(--text-2, #666);
}
.demo-includes {
    margin-top: 6px;
    font-size: 10.5px;
    color: var(--text-2, #888);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.demo-dl, .demo-dl-mini {
    text-decoration: none;
    text-align: center;
    font-weight: 600;
}
.demo-dl {
    display: block;
    margin: 4px 12px 14px;
    padding: 9px 14px;
    background: var(--primary, #0F3D2E);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    transition: background .15s ease;
}
.demo-dl:hover { background: #0a2e22; }
.demo-dl-group {
    display: flex;
    gap: 6px;
    margin: 4px 12px 14px;
}
.demo-dl-mini {
    flex: 1;
    padding: 8px 6px;
    background: var(--accent2, #7B6F4D);
    color: #fff;
    border-radius: 8px;
    font-size: 12px;
}
.demo-dl-mini:hover { filter: brightness(0.92); }
.demo-dl-mini i { margin-right: 4px; opacity: .85; }
/* Mobile tweaks — single column on phone, larger touch targets */
@media (max-width: 640px) {
    .demos-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 0 14px;
    }
    .demo-card {
        max-width: 480px;
        margin: 0 auto;
    }
    .demo-topic { font-size: 15px; -webkit-line-clamp: 3; }
    .demo-stats { font-size: 12px; }
    .demo-includes { font-size: 11px; margin-top: 8px; }
    .demo-dl {
        font-size: 14px;
        padding: 11px 14px;
        margin: 6px 14px 14px;
    }
    /* Group of mini buttons — stack vertically with full-width buttons
       so text never gets cropped on narrow screens. */
    .demo-dl-group {
        flex-direction: column;
        gap: 6px;
        margin: 6px 14px 14px;
    }
    .demo-dl-mini {
        padding: 11px 12px;
        font-size: 13.5px;
        text-align: center;
    }
}
/* Tablet — 2 columns */
@media (min-width: 641px) and (max-width: 900px) {
    .demos-grid { grid-template-columns: repeat(2, 1fr); }
}
