/*
 * FLL Team Hub - shared styles.
 *
 * Loaded by base.html.twig with a <link> placed before every inline <style>, so
 * this file is the base layer: a page template may override anything here from
 * its own {% block stylesheets %}, never the other way round.
 */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-soft: #eff6ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;

    /* Where the header stops fitting on one row. CSS cannot read a custom property
       from inside a media query, so the two @media rules below still spell it out -
       but navbar_controller.js reads this one instead of carrying its own copy, so
       the number lives in two places rather than three. Change all of them together. */
    --nav-breakpoint: 1279px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Gives a keyboard ring to everything that styles no focus of its own -
   links, buttons, the header controls. It deliberately does not reach the
   form fields: their `.form-input:focus { outline: none }` rules are more
   specific and come later in the cascade, and they already mark focus with
   a border and shadow. */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- Header ---------- */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 3.5rem;
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}
.navbar-collapse {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}
.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    list-style: none;
    /* auto on the right keeps the links next to the brand and pushes search,
       season and user to the far edge. */
    margin-right: auto;
}
.navbar-nav a {
    display: block;
    padding: 0.4rem 0.45rem;
    border-radius: 0.4rem;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.navbar-nav a:hover { background: var(--gray-100); color: var(--gray-900); }
.navbar-nav a.active { color: var(--primary-dark); background: var(--primary-soft); }
.navbar-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

/* Hamburger - only ever visible below the breakpoint. */
.navbar-toggle {
    display: none;
    margin-left: auto;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    color: var(--gray-700);
    cursor: pointer;
}
.navbar-toggle:hover { background: var(--gray-100); }
.navbar-toggle-icon,
.navbar-toggle-icon::before,
.navbar-toggle-icon::after {
    display: block;
    width: 1.125rem;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.2s, background 0.2s;
}
.navbar-toggle-icon { position: relative; }
.navbar-toggle-icon::before { content: ''; position: absolute; top: -0.375rem; }
.navbar-toggle-icon::after { content: ''; position: absolute; top: 0.375rem; }
.navbar-toggle[aria-expanded="true"] .navbar-toggle-icon { background: transparent; }
.navbar-toggle[aria-expanded="true"] .navbar-toggle-icon::before {
    transform: translateY(0.375rem) rotate(45deg);
}
.navbar-toggle[aria-expanded="true"] .navbar-toggle-icon::after {
    transform: translateY(-0.375rem) rotate(-45deg);
}

/* Search */
.navbar-search { position: relative; flex-shrink: 0; }
.search-input {
    width: 8rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.4rem;
    background: var(--gray-50);
    font-size: 0.8125rem;
    font-family: inherit;
}
.search-input:focus {
    background: white;
    border-color: var(--primary);
}
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
}
.search-dropdown.hidden { display: none; }
.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.selected { background: var(--gray-50); }
.search-result-icon { font-size: 1.25rem; flex-shrink: 0; }
.search-result-content { flex: 1; min-width: 0; }
.search-result-title {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-subtitle {
    font-size: 0.75rem;
    color: var(--gray-500);
}
.search-result-type {
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
    flex-shrink: 0;
}
.search-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Season switcher */
.season-switcher { flex-shrink: 0; }
.season-switcher select {
    max-width: 8.5rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.4rem;
    background: var(--gray-50);
    color: var(--gray-700);
    font-size: 0.8125rem;
    font-family: inherit;
}

/* User menu */
.navbar-usermenu { position: relative; }
.navbar-usermenu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.6rem 0.25rem 0.25rem;
    border: 1px solid transparent;
    border-radius: 2rem;
    background: none;
    color: var(--gray-700);
    font: inherit;
    cursor: pointer;
    min-width: 0;
}
.navbar-usermenu-trigger:hover { background: var(--gray-100); }
.navbar-usermenu-trigger.active { color: var(--primary-dark); }
.navbar-avatar {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}
.navbar-usermenu-name {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
}
.navbar-usermenu-caret { font-size: 0.5rem; color: var(--gray-500); }
.navbar-usermenu-items {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    min-width: 12rem;
    padding: 0.35rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 200;
}
.navbar-usermenu.is-open .navbar-usermenu-items { display: block; }
.navbar-usermenu-items a,
.navbar-usermenu-items button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: none;
    border-radius: 0.375rem;
    background: none;
    color: var(--gray-700);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.navbar-usermenu-items a:hover,
.navbar-usermenu-items button:hover { background: var(--gray-100); }
.navbar-usermenu-items a.active { color: var(--primary-dark); }
.navbar-usermenu-sep {
    height: 1px;
    margin: 0.35rem 0;
    background: var(--gray-200);
}
/* Stands in for the trigger, which the panel hides on narrow screens. */
.navbar-usermenu-who { display: none; }

/* Keep in step with --nav-breakpoint above. */
@media (max-width: 1279px) {
    .navbar-toggle { display: flex; }
    .navbar-collapse {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        max-height: calc(100vh - 3.5rem);
        max-height: calc(100dvh - 3.5rem);
        padding: 0.75rem 1rem 1rem;
        overflow-y: auto;
        background: white;
        border-bottom: 1px solid var(--gray-200);
        box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    }
    .navbar.is-open .navbar-collapse { display: flex; }
    .navbar-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.125rem;
        margin-right: 0;
    }
    .navbar-nav a { padding: 0.6rem 0.65rem; font-size: 0.9375rem; }
    .navbar-tools {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--gray-200);
    }
    .navbar-search,
    .search-input,
    .season-switcher select { width: 100%; max-width: none; }
    /* In the panel the dropdown flows instead of floating: absolutely positioned
       with its own max-height it became a second scroll container inside the
       panel's, so results had to be scrolled through two nested boxes. */
    .search-dropdown {
        position: static;
        min-width: 0;
        max-height: none;
        margin-top: 0.4rem;
        border: 1px solid var(--gray-200);
        box-shadow: none;
    }
    /* display:none also drops it out of the tab order, so the panel never
       hands the keyboard a button that does nothing. */
    .navbar-usermenu-trigger { display: none; }
    .navbar-usermenu-items {
        display: block;
        position: static;
        min-width: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }
    .navbar-usermenu-who {
        display: block;
        padding: 0 0.6rem 0.4rem;
        color: var(--gray-500);
        font-size: 0.8125rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    .navbar-nav a,
    .navbar-toggle-icon,
    .navbar-toggle-icon::before,
    .navbar-toggle-icon::after { transition: none; }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
}
.main-content { padding: 2rem 0; }
.archive-banner {
    background: #fef3c7;
    border-bottom: 1px solid var(--warning);
    color: #78350f;
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.875rem;
}
.archive-banner-back {
    background: none;
    border: none;
    color: var(--primary-dark);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}
/* Not in the brief's CSS list, but the switcher's <label> uses this class and
   base.html.twig - unlike most page templates - never defined it: without this
   rule the label text would sit next to the select on every page. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Shared components
   --------------------------------------------------------------------------
   Each of these used to be copy-pasted into eight to eleven page templates,
   which is how they drifted apart. One definition each now; where two sizes
   are genuinely needed the second one is a named modifier rather than another
   silent copy.
   ========================================================================== */

/* ---------- Forms ---------- */
.form-container {
    max-width: 640px;
    margin: 0 auto;
}
/* The robot forms carry a photo gallery, which needs the extra room. */
.form-container--wide { max-width: 760px; }

.form-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-header { margin-bottom: 1.5rem; }
/* A heading that shares its line with an action button. */
.form-header--split {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Ticking off who came is done often, so every name is a full-width tap
   target rather than just the little box. */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .form-row,
    .checkbox-group { grid-template-columns: 1fr; }
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.delete-form {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.back-link {
    display: inline-block;
    margin-bottom: 0.5rem;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
}

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

/* ---------- Empty states ---------- */
.global-empty-state {
    background: white;
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}
.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}
.empty-state-description {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 1.5rem;
    color: var(--gray-500);
}
/* Inside a dashboard tile the full-size icon would dwarf the tile itself. */
.empty-state--compact .empty-state-icon {
    font-size: 1.5rem;
    margin-bottom: 0.375rem;
    opacity: 0.5;
}

/* ---------- Form controls ----------
   The fields themselves, which stayed behind when the form wrappers moved here:
   the same declarations were repeated in up to eight templates each. The focus
   rule below keeps its :root prefix even so - the file picker on the innovation
   attachment form is still described through an attribute selector, because it
   is deliberately a different control (dashed border, filled background) rather
   than another copy of these. */
.form-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    /* Without this a textarea renders in the browser's monospace default while the
       inputs beside it use the page font. Two of the eight copies had caught it. */
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
/* Dragging a textarea wider than its form breaks the layout; taller is harmless. */
.form-group textarea { resize: vertical; }

.back-link:hover { color: var(--primary); }

/* Ticking off a name is done often and usually on a phone, so the whole row is the
   target rather than the little box next to it. */
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    font-weight: normal;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.checkbox-group label:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}
.checkbox-group input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.assignee-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
}
/* Next to a heading rather than inside a list row. */
.assignee-avatar--lg {
    width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
}

/* ---------- Form control focus ----------
   This exact declaration was written out in nineteen templates. The border and
   the ring around it are the focus marker; a text field matches :focus-visible
   even when it was clicked, so there is no separate mouse and keyboard state to
   tell apart here.

   The :root prefix buys one class of specificity, and it is load-bearing. Three
   templates still style the resting field through an attribute selector
   (`.form-group input[type="text"]`), which scores exactly the same as
   `.form-group input:focus` - and since this file now loads first, an even score
   hands the win to the template and the border never turns blue. Those selectors
   cannot simply be widened to `.form-group input`: they are narrow on purpose, to
   keep checkboxes and file pickers out.

   Forced-colours mode throws box-shadow away, which would leave those fields with
   no focus marker at all, so an outline stands in for it there. It carries the
   same prefix - without it the `outline: none` above would outscore it. */
:root .form-input:focus,
:root .filter-input:focus,
:root .search-input-large:focus,
:root .judging-form-group input:focus,
:root .comment-form textarea:focus,
:root .form-group input:focus,
:root .form-group select:focus,
:root .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

@media (forced-colors: active) {
    :root .form-input:focus,
    :root .filter-input:focus,
    :root .search-input-large:focus,
    :root .judging-form-group input:focus,
    :root .comment-form textarea:focus,
    :root .form-group input:focus,
    :root .form-group select:focus,
    :root .form-group textarea:focus {
        outline: 2px solid;
        outline-offset: 1px;
    }
}
