/* Additions to Pico CSS. Mobile-first (NFR-UX-01). */

/* Club colours, taken from the RAC logo (img/rac-logo.svg) */
:root {
    --rac-teal: #006f66;
    --rac-teal-dark: #00524b;
    --rac-yellow: #fae467;
    --rac-green: #7daa67;
}

/* Selectors mirror Pico's own theme selectors so these overrides win */
:root:not([data-theme=dark]), [data-theme=light] {
    --pico-background-color: #f4f6f5;
    --pico-card-background-color: #fff;
    --pico-card-sectioning-background-color: #fff;
    --pico-primary: var(--rac-teal);
    --pico-primary-background: var(--rac-teal);
    --pico-primary-border: var(--rac-teal);
    --pico-primary-underline: rgba(0, 111, 102, 0.5);
    --pico-primary-hover: var(--rac-teal-dark);
    --pico-primary-hover-background: var(--rac-teal-dark);
    --pico-primary-hover-border: var(--rac-teal-dark);
    --pico-primary-hover-underline: var(--rac-teal-dark);
    --pico-primary-focus: rgba(0, 111, 102, 0.35);
    --pico-primary-inverse: #fff;
    --rac-heading: var(--rac-teal);
    --rac-header-background: var(--rac-teal);
}

@media only screen and (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --pico-primary: #4fc1b4;
        --pico-primary-background: #007a70;
        --pico-primary-border: #007a70;
        --pico-primary-underline: rgba(79, 193, 180, 0.5);
        --pico-primary-hover: #7ad3c8;
        --pico-primary-hover-background: #008f84;
        --pico-primary-hover-border: #008f84;
        --pico-primary-hover-underline: #7ad3c8;
        --pico-primary-focus: rgba(79, 193, 180, 0.4);
        --pico-primary-inverse: #fff;
        --rac-heading: #7ad3c8;
        --rac-header-background: #00453f;
        --pico-background-color: rgb(19, 22.5, 30.5);
        --pico-card-background-color: #181c25;
        --pico-card-sectioning-background-color: rgb(26, 30.5, 40.25);
    }
}

[data-theme=dark] {
    --pico-primary: #4fc1b4;
    --pico-primary-background: #007a70;
    --pico-primary-border: #007a70;
    --pico-primary-underline: rgba(79, 193, 180, 0.5);
    --pico-primary-hover: #7ad3c8;
    --pico-primary-hover-background: #008f84;
    --pico-primary-hover-border: #008f84;
    --pico-primary-hover-underline: #7ad3c8;
    --pico-primary-focus: rgba(79, 193, 180, 0.4);
    --pico-primary-inverse: #fff;
    --rac-heading: #7ad3c8;
    --rac-header-background: #00453f;
    --pico-background-color: rgb(19, 22.5, 30.5);
    --pico-card-background-color: #181c25;
    --pico-card-sectioning-background-color: rgb(26, 30.5, 40.25);
}

/* Site header: teal band with the logo and a yellow accent line */
body > header.site-header {
    padding-block: 0;
    margin-bottom: var(--pico-block-spacing-vertical);
    background: var(--rac-header-background);
    border-bottom: 4px solid var(--rac-yellow);
}

.site-header nav {
    flex-wrap: wrap;
    padding-block: 0.25rem;
}

.site-header nav a {
    --pico-color: rgba(255, 255, 255, 0.9);
    color: var(--pico-color);
}

.site-header nav a:hover, .site-header nav a:focus-visible {
    color: var(--rac-yellow);
}

.site-header .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.site-header .brand img {
    height: 2.5rem;
    width: auto;
}

.site-header .brand strong {
    font-size: 1.1rem;
    letter-spacing: 0.01em;
}

.site-header nav button.secondary.outline {
    --pico-color: #fff;
    --pico-border-color: rgba(255, 255, 255, 0.7);
    padding: 0.4rem 0.9rem;
}

.site-header nav button.secondary.outline:hover, .site-header nav button.secondary.outline:focus-visible {
    --pico-color: var(--rac-teal);
    --pico-background-color: var(--rac-yellow);
    --pico-border-color: var(--rac-yellow);
}

.site-header .lang-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-header .lang-switch a, .site-header .lang-switch span {
    display: flex;
    padding: 0;
    margin: 0;
}

.site-header .lang-switch img {
    display: block;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.site-header .lang-switch .current img {
    filter: grayscale(1);
    opacity: 0.45;
}

.site-header .lang-switch a:hover img, .site-header .lang-switch a:focus-visible img {
    box-shadow: 0 0 0 2px var(--rac-yellow);
}

@media (max-width: 30rem) {
    .site-header .brand strong {
        display: none;
    }
}

/* Section headings inside form cards */
article > h2 {
    font-size: 1.2rem;
    color: var(--rac-heading);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--rac-green);
}

main h1 {
    color: var(--rac-heading);
}

.container.narrow {
    max-width: 32rem;
}

.required {
    color: var(--pico-del-color);
    margin-left: 0.15rem;
}

.hint {
    color: var(--pico-muted-color);
    font-size: 0.875rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.user-profile {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--pico-spacing);
}

.user-profile small {
    color: var(--pico-muted-color);
}

form.inline {
    display: inline;
    margin: 0;
}

form.inline button {
    margin: 0;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--pico-border-radius);
    border-left: 4px solid;
}

.alert.success {
    border-color: var(--pico-ins-color);
    background: color-mix(in srgb, var(--pico-ins-color) 12%, transparent);
}

.alert.error {
    border-color: var(--pico-del-color);
    background: color-mix(in srgb, var(--pico-del-color) 12%, transparent);
}

.alert.info {
    border-color: var(--pico-primary);
    background: color-mix(in srgb, var(--pico-primary) 10%, transparent);
}

.field-error {
    color: var(--pico-del-color);
}

/* Large touch-friendly tiles for aircraft and yes/no (FR-FORM-02, FR-FORM-06) */
.tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: var(--pico-spacing);
}

.tile {
    position: relative;
    flex: 1 1 8rem;
    min-height: 3.5rem;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.tile input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.tile:has(input:checked) {
    border-color: var(--pico-primary-background);
    background: var(--pico-primary-background);
    color: var(--pico-primary-inverse);
}

.tile:has(input:focus-visible) {
    outline: 3px solid var(--pico-primary-focus);
    outline-offset: 2px;
}

.landing-row {
    border-bottom: 1px solid var(--pico-muted-border-color);
    margin-bottom: var(--pico-spacing);
}

.row-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: var(--pico-spacing);
}

button.small {
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    width: auto;
}

.submit-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.submit-row button {
    min-width: 14rem;
}

/* htmx indicator styles (htmx's own inline styles are disabled for the CSP) */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
    display: inline;
}

.status {
    font-weight: 600;
}

.status-invoiced {
    color: var(--pico-ins-color);
}

.status-problem {
    color: var(--pico-del-color);
}

.actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Admin menu in the header: the dropdown list is a light card, so its links use Pico's dropdown colours */
.site-header details.admin-menu {
    margin: 0;
}

.site-header details.admin-menu summary {
    --pico-color: rgba(255, 255, 255, 0.9);
    color: var(--pico-color);
    border: none;
    background: none;
    box-shadow: none;
}

.site-header details.admin-menu summary:hover, .site-header details.admin-menu summary:focus-visible {
    color: var(--rac-yellow);
}

.site-header details.admin-menu ul a {
    --pico-color: var(--pico-dropdown-color);
    color: var(--pico-color);
}

.site-header details.admin-menu ul a:hover, .site-header details.admin-menu ul a:focus-visible {
    color: var(--pico-primary);
}

/* Title with an action button next to it (admin lists) */
.page-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: var(--pico-spacing);
}

.page-heading h1 {
    margin: 0;
}

/* Exact GUIDs: shown for reference, not meant to be read */
.guid {
    color: var(--pico-muted-color);
    font-family: var(--pico-font-family-monospace);
    font-size: 0.75rem;
    word-break: break-all;
}

td .actions {
    gap: 0.5rem;
    flex-wrap: nowrap;
}

/* Callsigns, airport and article codes never break across lines */
.code, td > a > strong {
    white-space: nowrap;
}

/* dir="rtl" aligns the menu to the right edge; keep its items left-aligned */
.site-header details.admin-menu ul li {
    direction: ltr;
    text-align: left;
}

/* Filter bar of the registrations list: fields side by side where there is room */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0 1rem;
    align-items: end;
}

.pagination {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}
