/*
    Hverdagsturer — mobile-first stylesheet, sharing its design system with Rental
    Calendar's app.css (same tokens, same components) so the two apps read as one family.

      - 16px minimum on form controls, or iOS Safari zooms the page on focus.
      - 44px minimum on anything tappable (Apple's HIG figure).
      - env(safe-area-inset-*) so the sticky header clears the notch.
      - Nothing wider than the viewport: the page never scrolls sideways.
*/

:root {
    --accent: #512bd4;
    --accent-contrast: #ffffff;

    /* Same accent, used wherever it colours text, an icon, a thin border or an outline
       rather than filling a solid shape. Identical to --accent in light mode; dark mode
       overrides it below. */
    --accent-text: var(--accent);
    --danger: #b3261e;
    --warning: #b26a00;

    /* Affirmative green for "this trip is done" — a separate hue from --accent so
       completion reads at a glance, same treatment as --danger/--warning below. */
    --success: #2e7d32;
    --success-text: var(--success);

    --bg: #f6f6f8;
    --surface: #ffffff;
    --surface-alt: #f0f0f4;
    --text: #16161a;
    --text-muted: #6b6b76;
    --border: #e0e0e6;

    --radius: 12px;
    --radius-sm: 8px;

    --header-height: 52px;
    --tap: 44px;

    /* Tells the browser this page fully themes its own native form controls (date
       picker, checkbox) for both schemes — without this, some mobile browsers force
       their own dark-mode inversion onto native inputs regardless of our CSS, which is
       what caused near-invisible pale text in a completed trip's date field. */
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121216;
        --surface: #1c1c22;
        --surface-alt: #24242c;
        --text: #f2f2f5;
        --text-muted: #a0a0ad;
        --border: #34343e;

        /* Lighter tints of the same hues — the base colours are too dark to read
           clearly against a near-black page. */
        --accent-text: #9575cd;
        --success-text: #66bb6a;
    }
}

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

html {
    /* Stops iOS bumping text size when the device is rotated. */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    overscroll-behavior-y: contain;
}

a,
button,
[role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

h1 {
    font-size: 1.35rem;
    margin: 0 0 0.75rem;
}

h1:focus {
    outline: none;
}

/*
    The page title already shows in the sticky header, but the document still needs an
    <h1> — it's the focus target after navigation and the outline for screen readers.
    This keeps it available to assistive tech without drawing it twice.
*/
.visually-hidden-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

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

/* ---- App shell ---------------------------------------------------------- */

.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--header-height);
    padding: 0 0.75rem;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-header .brand {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .who {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0.75rem;
    padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
}

/* ---- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--tap);
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: transparent;
    color: var(--accent-text);
    border-color: var(--border);
}

.btn-small {
    min-height: 34px;
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ---- Forms -------------------------------------------------------------- */

.field {
    display: block;
    margin-bottom: 1rem;
}

.field > label,
.label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    /* 16px exactly — anything smaller makes iOS Safari zoom in on focus. */
    font-size: 1rem;
    font-family: inherit;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.trip-card:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 1px;
}

input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}

/*
    Two rounds of trying to theme this field for dark mode (color-scheme, then styling
    the -webkit-datetime-edit-* sub-fields directly) still left the digits unreadable on
    the phone this was actually tested on — evidently something in that browser's native
    rendering of a date input's value text ignores both. Rather than keep guessing at
    which override that browser needs, force this one field to always render as a plain
    light control: white background, dark text, hard-coded rather than themed. It won't
    match a dark page, but it is guaranteed legible everywhere, which matters more for a
    field this small.
*/
.trip-date-input {
    color-scheme: light;
    background: #ffffff;
    color: #16161a;
    border-color: #cfcfcf;
}

.invalid {
    outline: 1px solid var(--danger);
}

.valid.modified:not([type="checkbox"]) {
    outline: 1px solid var(--success);
}

.validation-message {
    display: block;
    margin-top: 0.25rem;
    color: var(--danger);
    font-size: 0.8rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dH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A2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ---- Toggle switch ----------------------------------------------------- */

.switch {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 48px;
    height: 30px;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch .track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    /* --border rather than --surface-alt: in dark mode those two tokens sit too close
       together to read as a visible pill against the card behind it. */
    background: var(--border);
    border: 1px solid var(--border);
    transition: background 0.15s ease;
    pointer-events: none;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    /* Fixed light thumb regardless of theme — stays visible against the track above in
       both light and dark, rather than tracking --surface (near-black in dark mode,
       which made the thumb disappear into its own track). */
    background: #ffffff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
    transition: transform 0.15s ease;
}

.switch input:checked + .track {
    /* --success-text rather than --success: the base green reads as too dark/muddy on
       a near-black card in dark mode, where --success-text is already the lighter tint
       used everywhere else for that reason. */
    background: var(--success-text);
    border-color: var(--success-text);
}

.switch input:checked + .track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .track {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.switch.switch-small {
    width: 38px;
    height: 24px;
}

.switch.switch-small .track::after {
    width: 18px;
    height: 18px;
}

.switch.switch-small input:checked + .track::after {
    transform: translateX(14px);
}

/* ---- Radio rows ----------------------------------------------------------- */

.radio-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.radio-row input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ---- Cards and notices --------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem;
    margin-bottom: 0.75rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.notice {
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.notice-error {
    color: var(--danger);
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.notice-warning {
    color: var(--warning);
    border-color: var(--warning);
    background: color-mix(in srgb, var(--warning) 10%, transparent);
}

.notice-ok {
    color: var(--accent-text);
    border-color: var(--accent-text);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ---- Sign-in / register -------------------------------------------------- */

.login {
    max-width: 380px;
    margin: 0 auto;
    padding-top: 2rem;
}

.login h1 {
    text-align: center;
    font-size: 1.6rem;
}

.login .lead {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login .alt-links {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.9rem;
}

.login .alt-links p {
    margin: 0.4rem 0;
}

/* ---- Trip list ------------------------------------------------------------ */

.trip-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Navn/Lengde stacked rather than side by side, so this group stays narrow enough that
   the hide-completed toggle never has to wrap onto its own row below. */
.trip-toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.trip-toolbar-group > span {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.trip-hide-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex-shrink: 0;
    padding-top: 1.5rem;
}

.trip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.trip-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid transparent;
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.trip-card.completed {
    background: color-mix(in srgb, var(--success-text) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--success-text) 35%, var(--border));
    border-left-color: var(--success-text);
}

.trip-card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.trip-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.trip-length {
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.trip-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.trip-card-bottom {
    margin-top: 0.65rem;
    align-items: center;
}

.trip-number {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.trip-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.trip-date-input {
    width: auto;
    min-height: 34px;
    font-size: 0.85rem;
    padding: 0.15rem 0.4rem;
}

.trip-switch-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.completed .trip-switch-label {
    color: var(--success-text);
    font-weight: 600;
}

/* ---- Wider screens -------------------------------------------------------- */

@media (min-width: 700px) {
    :root {
        --header-height: 58px;
    }

    .app-main {
        padding: 1.25rem;
    }
}
