/* ==========================================================================
   barrven: shared design system
   Every page loads this. Module stylesheets should build on these tokens
   (var(--...)) and components (.btn, .card, ...) rather than hard-coding
   their own colours, so all modules stay visually consistent.
   ========================================================================== */

/* ---- Design tokens ---- */
:root {
    color-scheme: dark;

    --bg: #0b0d12;
    --surface: #12151c;          /* cards, panels */
    --surface-2: #1a1e28;        /* inputs, nested panels, hover */
    --border: #232832;
    --border-soft: #23283280;
    --text: #e8eaf0;
    --text-dim: #9aa1b0;
    --accent: #6ee7ff;
    --accent-2: #a78bfa;
    --accent-gradient: linear-gradient(90deg, var(--accent), var(--accent-2));
    --on-accent: #0b0d12;        /* text on accent-coloured backgrounds */
    --success: #40c057;
    --danger: #f87171;
    --danger-strong: #e5484d;

    --radius: 14px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 10px 30px -12px #000000aa;
    --silver-gradient: linear-gradient(115deg, #8b919b 0%, #e9ecf0 22%, #ffffff 32%, #b4bac4 46%, #7d838d 60%, #dfe3e8 78%, #9aa0aa 100%);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --header-h: 64px;
    --content-w: 1000px;
    --wide-w: 1200px;
}

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

html {
    scroll-behavior: smooth;
    /* Reserve scrollbar space so the header doesn't shift between pages that
       do and don't scroll. */
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1100px 600px at 15% -10%, #1c2130 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 10%, #201a33 0%, transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
}

a { color: var(--accent); }
img, video { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- Header / nav ---- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    backdrop-filter: blur(10px);
    background: #0b0d12cc;
    border-bottom: 1px solid var(--border-soft);
}

.navbar {
    max-width: var(--wide-w);
    height: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    cursor: pointer;
}

.nav-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text);
    display: block;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-links {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.95rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.nav-links a:hover { color: var(--text); background: #ffffff0d; }
.nav-links a.active { color: var(--on-accent); background: var(--accent-gradient); }

/* ---- Silver shimmer ----
   Reusable shiny-silver surface with a slow sweeping highlight and a hover
   effect. Add class="silver-shimmer" to any element (best on small circles
   and pills). Text/icons on it use a dark colour. */
.silver-shimmer {
    background: var(--silver-gradient);
    background-size: 250% 250%;
    animation: silver-shimmer 4s ease-in-out infinite;
    box-shadow: inset 0 1px 1px #ffffffaa, inset 0 -1px 2px #00000066;
    color: var(--on-accent);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.silver-shimmer:hover {
    transform: scale(1.12);
    animation-duration: 1.5s;
    box-shadow: 0 0 12px 2px #dfe6f0aa, inset 0 1px 1px #ffffffcc, inset 0 -1px 2px #00000066;
}

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

@media (prefers-reduced-motion: reduce) {
    .silver-shimmer, .silver-shimmer:hover { animation: none; }
}

/* Projects dropdown: one pill (link + chevron) with a menu below it */
.nav-dropdown { position: relative; }

.nav-dropdown-group {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    transition: color 0.2s ease, background 0.2s ease;
}

.nav-dropdown-group:hover { background: #ffffff0d; }
.nav-dropdown-group.active,
.nav-dropdown-group.active:hover { background: var(--accent-gradient); }

.nav-links .nav-dropdown-group a,
.nav-links .nav-dropdown-group a:hover,
.nav-links .nav-dropdown-group a.active {
    background: none;
    padding-right: 4px;
}

.nav-dropdown-group.active a { color: var(--on-accent); }

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin: 0 7px 0 2px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.nav-dropdown-toggle svg { transition: transform 0.2s ease; }
.nav-dropdown-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    list-style: none;
    margin: 0;
    padding: 6px;
    background: #0b0d12f2;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px #00000066;
    backdrop-filter: blur(10px);
}

.nav-dropdown-menu[hidden] { display: none; }

.nav-dropdown-menu a {
    display: block;
    width: 100%;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; }

    .nav-dropdown-group { display: flex; width: 100%; border-radius: var(--radius-sm); }
    .nav-dropdown-group a { flex: 1; }

    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: 0;
        background: none;
        backdrop-filter: none;
        padding: 2px 0 2px 16px;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 2px;
        padding: 0 16px;
        background: #0b0d12f2;
        border-bottom: 1px solid transparent;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease, padding 0.25s ease;
    }

    .nav-links.open {
        max-height: 420px;
        padding: 10px 16px 18px;
        border-bottom-color: var(--border-soft);
    }

    .nav-links a { width: 100%; border-radius: var(--radius-sm); }
}

/* ---- Main content area ---- */
.site-main { margin: 0 auto; }

.site-main--default {
    max-width: var(--content-w);
    padding: 56px 24px 96px;
}

.site-main--wide {
    max-width: var(--wide-w);
    padding: 32px 20px 64px;
}

/* App pages that manage their own full-height layout (e.g. the drone) */
.site-main--app {
    max-width: none;
    padding: 0;
}

/* ---- Typography ---- */
h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 0 0 16px;
    line-height: 1.1;
}

h2 { font-size: 1.4rem; margin: 0 0 12px; }
h3 { font-size: 1.1rem; margin: 0 0 8px; }

.page-title { font-size: clamp(1.6rem, 4vw, 2.2rem); }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    margin: 0 0 12px;
}

.lede {
    font-size: 1.15rem;
    color: var(--text-dim);
    max-width: 60ch;
    margin: 0 0 32px;
}

.muted { color: var(--text-dim); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: var(--accent-gradient);
    color: var(--on-accent);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 30px -10px #6ee7ff55; }
.btn:active { transform: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover { border-color: var(--text-dim); box-shadow: none; }

.btn-danger { background: var(--danger); color: var(--on-accent); }
.btn-danger:hover { box-shadow: 0 10px 30px -10px #f8717166; }

.btn-ghost {
    background: none;
    color: var(--text-dim);
    border-color: transparent;
}

.btn-ghost:hover { color: var(--text); box-shadow: none; }

.btn-sm { padding: 6px 14px; font-size: 0.9rem; }
.btn-block { width: 100%; }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.card h3 { margin: 0 0 8px; }
.card p { margin: 0; color: var(--text-dim); font-size: 0.95rem; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 12px;
}

.card-link {
    display: inline-block;
    margin-top: 14px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.card-link:hover { text-decoration: underline; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { color: var(--text-dim); font-size: 0.85rem; }

.input,
select.input,
input[type="text"].input,
input[type="file"].input {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    width: 100%;
}

.input:focus { border-color: var(--accent); outline: none; }

input[type="file"].input::file-selector-button {
    font: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 12px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--accent-gradient);
    color: var(--on-accent);
    cursor: pointer;
}

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 16px;
}

.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-success { border-color: var(--success); color: var(--success); }

/* ---- Dialog / modal ---- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #000000b3;
    animation: dialog-fade .2s ease-out;
}

.dialog-overlay.is-closing { animation: dialog-fade .15s ease-in reverse forwards; }
.dialog-overlay.is-closing .dialog { animation: dialog-pop .15s ease-in reverse forwards; }

@keyframes dialog-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .dialog-overlay, .dialog { animation: none !important; } }

.dialog {
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    animation: dialog-pop .25s cubic-bezier(.2, .8, .2, 1);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.dialog-header h2 { margin: 0; font-size: 1.2rem; }

.dialog-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 8px;
}

.dialog-close:hover { color: var(--text); }

/* ---- Error page ---- */
.error-page { padding-top: 24px; }

.debug-trace {
    margin-top: 32px;
    padding: 16px;
    overflow-x: auto;
    font-size: 0.8rem;
    color: var(--text-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.older-projects-repo { margin-top: 24px; }
.older-projects { margin-top: 48px; }

.demo-videos { margin-top: 48px; }
.demo { padding: 28px 0; border-top: 1px solid var(--border); }
.demo h3 { margin: 0 0 10px; }
.demo ul { color: var(--text-dim); padding-left: 1.2rem; }
.demo p { color: var(--text-dim); }
.video-frame { position: relative; aspect-ratio: 16 / 9; max-width: 640px; margin: 16px 0; border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---- Contact dialog ---- */
.contact-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
textarea.input { resize: vertical; }
.nav-links .nav-contact {
    display: inline-block;
    padding: 8px 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: none;
    color: var(--text-dim);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}
.nav-links .nav-contact:hover { color: var(--text); background: #ffffff0d; }
@media (max-width: 720px) { .nav-links .nav-contact { width: 100%; border-radius: var(--radius-sm); text-align: left; } }
