/* Only what Web Awesome has no component for: pinned bars, floating button, hiding screens.
   Everything else (type, colours, spacing, components) is Web Awesome's default. */
/* Outfit (SIL Open Font License, see fonts/outfit/OFL.txt): the app font, hosted in the project so it works offline. Variable weight 300-700. */
@font-face {
  font-family: 'Outfit'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('../fonts/outfit/outfit-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Outfit'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('../fonts/outfit/outfit-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --nav-height: 4rem; /* the tab bar without the safe area below it (measured in app.js) */
  --sab: env(safe-area-inset-bottom, 0px); /* space under the screen taken by the phone or the browser: it changes while the browser's own toolbar slides in and out */
  --wa-font-family-body: 'Outfit', ui-sans-serif, system-ui, sans-serif; /* Outfit is the app font (headings follow the body font) */
}

[hidden] { display: none !important; }

/* Loading cover: sits over the whole app until it is ready, and takes every tap while it is there. */
#app-loading { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--wa-color-surface-default); }

main {
  padding: var(--wa-space-m) var(--wa-space-m) calc(var(--nav-height) + var(--sab) + 6rem);
}

/* Floating "New report" button (Web Awesome has no FAB): a wa-button, positioned. */
#fab {
  position: fixed;
  right: var(--wa-space-m);
  bottom: calc(var(--nav-height) + var(--sab) + var(--wa-space-m)); /* sits above the tab bar, whatever the safe area below it is right now */
  z-index: 9;
}

/* While the menu is open the button becomes a close button: the label collapses and the plus turns 225 degrees (45 + a half turn, since a plus looks the same every 90) into an x.
   It is driven by aria-expanded, so closing (even by tapping outside) plays it backwards. */
#fab > span[data-i18n] { display: block; overflow: hidden; white-space: nowrap; max-width: var(--fab-label-w, 12em); transition: max-width 300ms ease-out, opacity 300ms ease-out; }
#fab[aria-expanded="true"] > span[data-i18n] { max-width: 0; opacity: 0; }
#fab wa-icon { transition: transform 300ms ease-out, margin 300ms ease-out; }
#fab[aria-expanded="true"] wa-icon { transform: rotate(225deg); margin-inline-end: 0; }
/* Same height as before; the side padding grows until the width equals the height (icon 20px), so the pill becomes a circle. */
#fab::part(base) { transition: padding-inline 300ms ease-out; }
#fab[aria-expanded="true"]::part(base) { padding-inline: calc((var(--fab-h) - 20px) / 2); }
@media (prefers-reduced-motion: reduce) { #fab > span[data-i18n], #fab wa-icon, #fab::part(base) { transition: none; } }

/* "New report" menu: sits right above the floating button, right-aligned. */
#fab-menu {
  position: fixed; right: var(--wa-space-m); z-index: 9;
  bottom: calc(var(--nav-height) + var(--sab) + var(--wa-space-m) + var(--fab-height, 2.5rem) + var(--wa-space-s));
  max-width: calc(100vw - 2 * var(--wa-space-m));
}

/* Report page: the PDF buttons stick to the bottom (just above the tab bar) while the page scrolls, and settle in their own place in the page, above the download buttons. They are a direct child of #detail-body so they can stick for its whole height. */
.detail-sticky {
  position: sticky; z-index: 9;
  bottom: calc(var(--nav-height) + var(--sab));
  padding-block: var(--wa-space-s);
  margin-block-end: calc(var(--wa-space-m) - var(--wa-space-s) - var(--wa-space-xl)); /* the gap to the buttons below is the same as between any two buttons, not the large gap between sections */
  background: var(--wa-color-surface-default);
}
.detail-sticky wa-button { flex: 1 1 auto; }
.detail-sticky:has(.detail-sticky-note) { row-gap: calc(var(--wa-space-2xs) + 2px); } /* the sentence sits close to its button */
.detail-sticky-note { flex: 1 1 100%; margin: 0; text-align: center; } /* the sentence under the button: its own full-width row, centred */

/* The page leaves room for the pinned buttons, so a field or button that gets focus is never hidden behind them. */
html { scroll-padding-bottom: calc(var(--nav-height) + var(--sab) + 6rem); }

/* Bottom tabs: Web Awesome's wa-tab-group, pinned to the bottom of the screen. */
#tabs[hidden] { display: none; }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--wa-color-surface-default);
  padding-bottom: var(--sab);
}

/* Custom tab group variant: "app-bottom-tabs". Still Web Awesome's wa-tab-group, made to feel like a native app bottom bar.
   Equal-width tabs, icon above label, 12px bold label, 4px gap, icon 28px, bar at least 64px tall. */
.app-bottom-tabs::part(nav) { min-height: 64px; }
.app-bottom-tabs wa-tab { flex: 1 1 0; font-size: 12px; }
.app-bottom-tabs wa-tab::part(base) {
  width: 100%;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--wa-space-2xs);
  font-weight: 600;
}
.app-bottom-tabs wa-tab wa-icon { font-size: calc(var(--wa-font-size-m) * 2 - 4px); margin: 0; } /* wa-tab adds a right margin for side-by-side icons; it pushes a stacked icon off-centre */

/* Override: the header h1 is a tab section title: half of Web Awesome's default h1 size.
   The header's bottom border uses the same light grey as the line above the bottom tab bar (the tab group's default track colour). */
.app-section-title { font-size: calc(var(--wa-font-size-3xl) / 2); }
header[slot="header"] { border-bottom: var(--wa-border-width-m) solid var(--wa-color-neutral-fill-normal); height: 4.5rem; box-sizing: border-box; } /* same header height (72px) on every screen */
/* Header: one row that never wraps. The badge and the logo keep their size; the title and the line under it get shorter ("…") when there is no room. */
.app-header { flex-wrap: nowrap; min-width: 0; } /* min-width 0: the header may be as narrow as the screen, so the titles inside it can shrink */
.app-header .header-titles { flex: 0 1 auto; min-width: 0; }
.app-header .header-titles > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#header-badge, #header-logo, #back-button { flex: none; }
#screen-title { line-height: 1; } /* tight line heights so the title plus the small line under it fit in 72px */
#screen-subtitle { line-height: 1; }
#header-badge { margin-inline-start: auto; } /* status badge: top right of the header */
/* Logo: top right of the header on Home, Reports and Settings. Black logo in light mode, white in dark mode. */
#header-logo { margin-inline-start: auto; display: flex; }
#header-logo svg { display: block; height: var(--wa-space-2xl); width: auto; color: var(--wa-color-text-normal); } /* the logo takes the text colour: dark in light mode, light in dark mode */
/* Animated logo (from icons/logo-02-animated-mono.svg): 10 s loop, rest, then the top car bumps the stem, then the lower car does. */
#header-logo .stem { fill: currentColor; animation: sf-stem 10s infinite; }
#header-logo .arm { fill: none; stroke: currentColor; stroke-width: 16; stroke-linecap: round; stroke-linejoin: round; }
#header-logo .arm-top { animation: sf-arm-top 10s infinite; }
#header-logo .arm-bottom { animation: sf-arm-bottom 10s infinite; }
@keyframes sf-arm-top {
  0%, 35% { transform: translateX(0); animation-timing-function: ease-out; }
  36.5% { transform: translateX(3px); animation-timing-function: ease-in; }
  37.75% { transform: translateX(-19px); animation-timing-function: ease-out; }
  41.5%, 100% { transform: translateX(0); }
}
@keyframes sf-arm-bottom {
  0%, 40% { transform: translateX(0); animation-timing-function: ease-out; }
  41.5% { transform: translateX(3px); animation-timing-function: ease-in; }
  42.75% { transform: translateX(-19px); animation-timing-function: ease-out; }
  46.5%, 100% { transform: translateX(0); }
}
@keyframes sf-stem {
  0%, 37.5% { transform: translateX(0); animation-timing-function: ease-out; }
  37.75% { transform: translateX(-5px); animation-timing-function: ease-out; }
  41% { transform: translateX(0); }
  42.75% { transform: translateX(-5px); animation-timing-function: ease-out; }
  46%, 100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) { #header-logo .stem, #header-logo .arm { animation: none; } }

/* Override: "How it works" steps all look the same as the stepper's current step (strong fill).
   wa-stepper always treats step 1 as current and has no option to turn that off. */
.numbered-steps wa-step { --_filled: var(--wa-color-fill-loud); --_filled-on: var(--wa-color-on-loud); } /* only steppers with the class "numbered-steps" (Home "How it works", Review "What happens next"); every other stepper uses Web Awesome's defaults */

/* ---- New-report flow (layout only) ---- */
/* Full-screen viewfinder. Black and white because it sits over the live camera image. */
body.camera-open { overflow: hidden; }
#camera { position: fixed; inset: 0; z-index: 100; background: black; color: white; }
#cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#cam-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--wa-space-m) + env(safe-area-inset-top)) var(--wa-space-m) var(--wa-space-m); }
#cam-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: var(--wa-space-m) var(--wa-space-m) calc(var(--wa-space-m) + env(safe-area-inset-bottom)); }
/* Controls row: shutter centred, Next on the right, both on the same centre line. */
#cam-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
#cam-shutter { grid-column: 2; }
#cam-next { grid-column: 3; justify-self: end; }
#cam-thumbs img { width: 48px; height: 48px; object-fit: cover; border-radius: var(--wa-border-radius-m); }

#flow-delete { margin-inline-end: auto; } /* "Delete draft" sits alone on the left of the footer */
/* Bottom drawer, about 95% of the screen. Footer clears the Android navigation bar. */
#flow-drawer { --size: 95dvh; }
/* The step indicator stays visible at the top of the drawer content while the rest scrolls. */
#flow-drawer::part(body) { padding-top: 0; scroll-padding-top: calc(var(--flow-stepper-h, 6rem) + var(--wa-space-s)); } /* this drawer only: the stepper starts right under the header. The scroll padding is the height of the sticky stepper (set from the code), so a field the browser scrolls to (for example the first required field left empty) stops below the stepper, not behind it */
#flow-stepper { position: sticky; top: 0; z-index: 5; background: var(--wa-color-surface-raised); padding-block: var(--wa-space-2xs) var(--wa-space-m); } /* 4px above, 16px below */
#flow-drawer::part(close-button__base) { border-radius: var(--wa-border-radius-pill); } /* the drawer's own close button is built inside the component, so pill is set from outside */
/* Same 2px line as the app header and the tab bar. */
#flow-drawer::part(footer) { border-top: var(--wa-border-width-m) solid var(--wa-color-neutral-fill-normal); padding-block-end: var(--wa-space-m); } /* 16px below the buttons, the same as the 16px above them (the drawer's own footer has 24px below) */
#flow-footer { flex: 1; justify-content: flex-end; padding-top: var(--wa-space-m); padding-bottom: var(--sab); } /* the drawer footer has no top padding of its own */

/* Photos in the Offence step: three equal squares across the width. Photos first, then the "+" button, then blank squares. */
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--wa-space-xs); }
.photo-cell { position: relative; aspect-ratio: 3 / 4; } /* every photo thumbnail is 3:4, cropped to fill (cover) */
.photo-cell wa-lightbox-item { display: block; }
/* The lightbox item wraps the photo in an element of its own with no fixed height, so a percentage height cannot work here:
   the photo itself is given the 3:4 shape, and cover crops it to fill it, whatever the photo's own shape. */
.photo-cell img { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--wa-border-radius-m); display: block; cursor: zoom-in; }
.photo-add { display: block; width: 100%; aspect-ratio: 3 / 4; }
/* The "+" is the one square button (owner's decision, an exception to the pill rule): same size and corner radius as the photos. */
.photo-add::part(base) { width: 100%; height: 100%; border-radius: var(--wa-border-radius-m); }
.photo-add wa-icon { font-size: var(--wa-font-size-l); }
/* Our own button variant: variant="inverted" (neutral, inverted), for buttons that sit on photos or other media. It is always white, in light and in dark mode.
   It is built the way Web Awesome builds its own variants (.wa-brand, .wa-danger...): a set of nine colour variables, so it works with every
   appearance, size, pill, loading state and link button, with no new component. (The wa-dark class does not do this: the variant colours
   are worked out once on the page root and are not recalculated inside the element.) */
wa-button[variant="inverted"] {
  --wa-color-fill-loud: white;
  --wa-color-fill-normal: rgb(0 0 0 / 0.45);
  --wa-color-fill-quiet: transparent;
  --wa-color-border-loud: white;
  --wa-color-border-normal: rgb(255 255 255 / 0.7);
  --wa-color-border-quiet: transparent;
  --wa-color-on-loud: rgb(0 0 0 / 0.85);
  --wa-color-on-normal: white;
  --wa-color-on-quiet: white;
}
.thumb-remove { position: absolute; top: var(--wa-space-2xs); right: var(--wa-space-2xs); }
.review-photos img { width: 4rem; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--wa-border-radius-m); }


/* Postal code and city stay side by side, even on a phone: one third and two thirds. Same class in Settings and in the report drawer. */
/* Two equal columns that stay side by side on a phone (used for pairs like make and model). */
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.postal-city { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

/* Home screen only: extra space above the first section and below the last. */
#screen-home { padding-block: var(--wa-space-xl); }

/* Report cards: Web Awesome has no size setting for a card's photo or its padding, so: a small fixed-width photo that
   fills the card's full height, and a smaller card padding. */
.report-card { --spacing: var(--wa-space-s); box-shadow: none; } /* no drop shadow on cards (owner's decision) */
.report-card::part(media) { position: relative; flex: none; width: 4.6rem; align-self: stretch; } /* about 3:4: every card is the same height (3 lines of text), so a fixed width gives a 3:4 thumbnail; the photo is cropped to fit (cover) */
.report-card::part(body) { min-width: 0; flex: 1; } /* lets the street shrink and truncate instead of widening the card */
.report-text { min-width: 0; flex: 1; } /* the text group fills the space; badge and chevron hug the right edge */
.report-link { display: block; text-decoration: none; color: inherit; } /* the whole card is one link */
.report-card [slot="actions"] { gap: var(--wa-space-xs); margin-inline-end: -5px; } /* badge to chevron 8px; chevron to card edge 8px */
.report-street { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* street on one line */
.report-card .no-photo { position: absolute; inset: 0; display: grid; place-items: center; background: var(--wa-color-neutral-90); color: var(--wa-color-neutral-60); font-size: var(--wa-font-size-2xl); } /* no photo: grey canvas, car icon in a mid grey */
.report-card img[slot="media"] { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; } /* the photo fills the card but never sets its height: the text decides */

/* Language and appearance pickers: the button-style radios share the full width equally. */
#language-group wa-radio, #theme-group wa-radio { flex: 1 1 0; justify-content: center; }

/* Report photos on the detail page: the Web Awesome lightbox is the gallery. Three equal columns of 3:4 previews, cropped to fill; tap one to open it. */
#detail-photos { grid-template-columns: repeat(3, 1fr); }
#detail-photos, .photo-grid { --spacing: var(--wa-space-2xs); } /* the lightbox's side padding (16px by default): small, so full-screen photos use nearly the whole width */
#detail-photos img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--wa-border-radius-m); }

/* Swipe a report card left to reveal Delete. Web Awesome's scroller has no scroll-snap part, so this is a plain scroll container:
   the card fills the row, the full-height Delete button waits just past its right edge, and the row snaps to one or the other. */
.swipe-track { display: flex; gap: var(--wa-space-s); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.swipe-track::-webkit-scrollbar { display: none; }
.swipe-card { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
.swipe-delete { flex: none; width: 4.5rem; align-self: stretch; scroll-snap-align: end; }
.swipe-delete::part(base) { width: 100%; height: 100%; }

/* The small hint line under an option name (the offence list): the option's own text colour at 70%, so it is softer than the name on any
   background. A fixed grey did not work on the highlighted option (white-on-teal): there it goes back to full strength to stay readable. */
.option-hint { color: inherit; opacity: 0.7; }
wa-option:hover .option-hint, wa-option:state(current) .option-hint { opacity: 1; }

/* The steps at the top of the new-report drawer can be tapped (all but the first, which is never a step to go back to). */
#flow-stepper wa-step:not([name="photos"]) { cursor: pointer; }
