/* 1. Spåret variables */
:root {
    --sp-orange: #F26A1B;
    --sp-dark: #1F2A1F;
    --sp-paper: #F7F3EA;
    --sp-contour: #8B693E;
    --sp-green: #2E9E5B;
    --sp-red: #B3261E;
    --sp-sand: #E4DDCF;
    --sp-radius: 12px;
    --sp-border: 2px;
    --sp-font: 'Bricolage Grotesque', system-ui, sans-serif;
    --sp-tight: -0.03em;
}

/* 2. Bootstrap variables set from the Spåret variables */
:root {
    --bs-primary: var(--sp-orange);
    --bs-primary-rgb: 242, 106, 27;
    --bs-dark: var(--sp-dark);
    --bs-dark-rgb: 31, 42, 31;
    --bs-body-bg: var(--sp-paper);
    --bs-body-bg-rgb: 247, 243, 234;
    --bs-body-color: var(--sp-dark);
    --bs-body-color-rgb: 31, 42, 31;
    --bs-body-font-family: var(--sp-font);
    --bs-border-radius: var(--sp-radius);
    --bs-border-width: var(--sp-border);
    --bs-border-color: var(--sp-dark);
    --bs-success: var(--sp-green);
    --bs-success-rgb: 46, 158, 91;
    --bs-danger: var(--sp-red);
    --bs-danger-rgb: 179, 38, 30;
    --bs-secondary-bg: var(--sp-sand);
    --bs-secondary-bg-rgb: 228, 221, 207;
    --bs-link-color: var(--sp-dark);
    --bs-link-color-rgb: 31, 42, 31;
    --bs-link-hover-color-rgb: 242, 106, 27;
}

/* Placeholders lighter than the help texts: Bootstrap uses --bs-secondary-color for both, so it is overridden on the fields only. */
.form-control {
    --bs-secondary-color: rgba(var(--bs-body-color-rgb), .4);
}

.btn-primary,
.btn-dark,
.btn-outline-dark {
    --bs-btn-padding-x: 16px;
    --bs-btn-padding-y: 14px;
    --bs-btn-font-size: 15px;
    --bs-btn-font-weight: 700;
    --bs-btn-border-width: var(--sp-border);
    --bs-btn-border-radius: var(--sp-radius);
}

.btn-primary {
    --bs-btn-color: white;
    --bs-btn-bg: var(--sp-orange);
    --bs-btn-border-color: var(--sp-dark);
    --bs-btn-hover-color: white;
    --bs-btn-hover-bg: color-mix(in srgb, var(--sp-orange) 85%, black);
    --bs-btn-hover-border-color: var(--sp-dark);
    --bs-btn-active-color: white;
    --bs-btn-active-bg: color-mix(in srgb, var(--sp-orange) 75%, black);
    --bs-btn-active-border-color: var(--sp-dark);
    --bs-btn-disabled-color: white;
    --bs-btn-disabled-bg: var(--sp-orange);
    --bs-btn-disabled-border-color: var(--sp-dark);
}

.btn-dark {
    --bs-btn-color: white;
    --bs-btn-bg: var(--sp-dark);
    --bs-btn-border-color: var(--sp-dark);
    --bs-btn-hover-color: white;
    --bs-btn-hover-bg: color-mix(in srgb, var(--sp-dark) 85%, white);
    --bs-btn-hover-border-color: var(--sp-dark);
    --bs-btn-active-color: white;
    --bs-btn-active-bg: color-mix(in srgb, var(--sp-dark) 75%, black);
    --bs-btn-active-border-color: var(--sp-dark);
    --bs-btn-disabled-color: white;
    --bs-btn-disabled-bg: var(--sp-dark);
    --bs-btn-disabled-border-color: var(--sp-dark);
}

.btn-outline-dark {
    --bs-btn-color: var(--sp-dark);
    --bs-btn-bg: white;
    --bs-btn-border-color: var(--sp-dark);
    --bs-btn-hover-color: var(--sp-dark);
    --bs-btn-hover-bg: var(--sp-sand);
    --bs-btn-hover-border-color: var(--sp-dark);
    --bs-btn-active-color: white;
    --bs-btn-active-bg: var(--sp-dark);
    --bs-btn-active-border-color: var(--sp-dark);
    --bs-btn-disabled-color: var(--sp-dark);
    --bs-btn-disabled-bg: white;
    --bs-btn-disabled-border-color: var(--sp-dark);
}

/* 3. What Bootstrap lacks */
body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-x: hidden;
}

/* No zooming on phones and tablets (the owner's choice: zooming made the app hard to use). iOS Safari ignores
   user-scalable=no in the viewport, so: no pinch zoom anywhere (scrolling still works), and no double-tap zoom on
   what gets tapped. On every element, not just html: Safari starts afresh at each element that can scroll, and body
   is one (its overflow-x: hidden makes overflow-y auto), so a rule on html alone let the whole page zoom. */
* {
    touch-action: pan-x pan-y;
}

button, a, input, select, textarea, summary, label, .btn {
    touch-action: manipulation;
}

/* iOS zooms into a focused field whose text is under 16 px: no field smaller than the body text. Bootstrap's own
   sizes (.form-control 16 px, -lg 20 px, the code field 28 px) are larger and win over these element rules. */
input, textarea, select {
    font-size: max(var(--bs-body-font-size), 1em);
}

.form-control-sm,
.form-select-sm {
    font-size: var(--bs-body-font-size);
}

/* Below 768 px one column with 16 px gutters; from 768 px centred, at most 720 px wide. */
.container {
    --bs-gutter-x: 32px;
    max-width: 720px;
}

h1, h2, h3, .display-6 {
    letter-spacing: var(--sp-tight);
}

.sp-contours {
    background-attachment: fixed;
    background-image:
        repeating-radial-gradient(circle at 15% 115%, transparent 0 30px, color-mix(in srgb, var(--sp-contour) 15%, transparent) 30px 31px),
        repeating-radial-gradient(circle at 115% 5%, transparent 0 38px, color-mix(in srgb, var(--sp-contour) 15%, transparent) 38px 39px);
}

.sp-progress {
    display: flex;
    gap: 4px;
}

.sp-progress .seg {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--sp-sand);
}

.sp-progress .seg.done {
    background: var(--sp-orange);
}

.sp-progress .seg.current {
    background: var(--sp-dark);
}

/* The compass on the way to a stop: a white ring with ticks, N and the orange arrow round the map to the stop, which
   turns with the team (sparet.js), so the arrow on the ring and the stop on the map point the same way. Orange with a
   white arrow straight up on arrival. Full width up to 320 px on a phone, 420 px beside the clue from 768 px. */
.sp-compass {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 50%;
    background: white;
    border: var(--sp-border) solid var(--sp-dark);
}

.sp-compass.arrived {
    background: var(--sp-orange);
}

/* The map's circle, a tenth of the width in from the edge: the ring is what is left. clip-path keeps the turned
   square of the map inside the circle, which border-radius and overflow alone do not do in every Safari. */
.sp-compass-face {
    position: absolute;
    inset: 10%;
    border: var(--sp-border) solid var(--sp-dark);
    border-radius: 50%;
    overflow: hidden;
    clip-path: circle(50%);
    background: var(--sp-paper);
}

/* Over the face, so the arrow and the ticks stay on the ring; in viewBox units, the ring is 10 wide. */
.sp-compass-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* In CSS, not as an SVG attribute: var() in presentation attributes is not reliable in Safari. */
.sp-compass-arrow path {
    stroke: var(--sp-dark);
}

/* The compass updates four times a second (sparet.js): the arrow and the rose glide to each new angle over that
   quarter second instead of jumping, and Compass.razor turns them the short way round. The reduced-motion rule
   further down switches the glide off. */
.sp-compass-arrow,
.sp-compass-rose {
    transition: transform 0.25s linear;
}

/* Turned with a CSS transform, so they can glide; about the ring's centre. */
.sp-compass-arrow,
.sp-compass-rose {
    transform-box: view-box;
    transform-origin: 50% 50%;
}

/* The distance on a badge at the bottom of the map: that part is behind the team, the least needed while walking. */
.sp-distance {
    position: absolute;
    left: 50%;
    bottom: 9%;
    z-index: 1;
    transform: translateX(-50%);
    padding: 4px 14px;
    border: var(--sp-border) solid white;
    border-radius: 999px;
    background: var(--sp-dark);
    color: white;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: var(--sp-tight);
    white-space: nowrap;
}

/* Words are wider than a distance: a little higher up, where the circle is wide enough for them on a 320 px phone. */
.sp-distance.searching {
    bottom: 14%;
    padding: 6px 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: normal;
}

/* The badge as a button, orange as every button that moves the round on. */
.sp-distance.sp-location-tap {
    background: var(--sp-orange);
}

.sp-distance.sp-location-tap:active {
    background: color-mix(in srgb, var(--sp-orange) 75%, black);
}

.sp-arrived-title {
    font-size: 40px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: var(--sp-tight);
}

/* The map fills the face; isolation keeps Leaflet's own z-indexes under the badge. */
.sp-map {
    position: absolute;
    inset: 0;
    isolation: isolate;
}

.sp-map-turn {
    position: absolute;
    inset: 0;
    transition: transform 0.25s linear;
}

/* OpenStreetMap's credit under the circle, as small as it can be and still be read; not while the map is empty
   (Leaflet did not load). */
.sp-map-credit {
    margin-top: 2px;
    font-size: 10px;
    line-height: 1.2;
}

.sp-compass:not(:has(.leaflet-container)) + .sp-map-credit {
    display: none;
}

@media (min-width: 768px) {
    .sp-compass {
        max-width: 420px;
    }

    .sp-distance {
        font-size: 34px;
    }
}

.sp-hero-number {
    font-size: 60px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: var(--sp-tight);
    color: var(--sp-orange);
}

/* The question and the finish: one column, at most 560 px wide, centred on wider screens. */
.sp-narrow {
    max-width: 560px;
    margin-inline: auto;
}

/* Answer options: a white row with the label 1, X, 2 … in a square; orange when chosen, red after a wrong answer.
   The answer that completed a stop is shown dark. */
.sp-option {
    --bs-btn-padding-x: 12px;
    --bs-btn-padding-y: 9px;
    --bs-btn-font-size: 16px;
    --bs-btn-font-weight: 600;
    --bs-btn-active-color: var(--sp-dark);
    --bs-btn-active-bg: color-mix(in srgb, var(--sp-orange) 15%, white);
    --bs-btn-active-border-color: var(--sp-orange);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    text-align: start;
}

.sp-option.sp-wrong {
    --bs-btn-border-color: var(--sp-red);
    --bs-btn-hover-border-color: var(--sp-red);
}

.sp-answer {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 9px 12px;
    border: var(--sp-border) solid var(--sp-dark);
    border-radius: var(--sp-radius);
    background: var(--sp-dark);
    color: white;
    font-weight: 600;
}

.sp-option-label {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--sp-sand);
    font-size: 14px;
    font-weight: 800;
}

.sp-option.active .sp-option-label,
.sp-answer .sp-option-label {
    background: var(--sp-orange);
    color: white;
}

.sp-option.sp-wrong .sp-option-label {
    background: var(--sp-red);
    color: white;
}

.sp-option-text {
    overflow-wrap: anywhere;
}

/* The question's image: full width, but never so tall that the options drop out of sight; the whole image stays visible. */
.sp-question-image {
    max-height: 45vh;
    object-fit: contain;
}

/* "Rätt!": the Spåret green instead of Bootstrap's compiled success tints (the 2 px border comes from --bs-border-width). */
.sp-correct {
    --bs-alert-color: color-mix(in srgb, var(--sp-green) 70%, black);
    --bs-alert-bg: color-mix(in srgb, var(--sp-green) 15%, white);
    --bs-alert-border-color: var(--sp-green);
}

/* Information, not an error (the team was removed and can start over): sand with the dark text. */
.alert-secondary {
    --bs-alert-color: var(--sp-dark);
    --bs-alert-bg: var(--sp-sand);
    --bs-alert-border-color: var(--sp-dark);
}

/* The join code: large, spaced like the printed code. */
.sp-code-input {
    height: 64px;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.sp-code {
    letter-spacing: 0.06em;
}

/* Numbered steps on the start page and the waiting dots on the not-open page. */
.sp-step {
    width: 36px;
    height: 36px;
}

.sp-step-sm {
    width: 28px;
    height: 28px;
}

/* "Ingen app behövs" by the join form: the green of a correct answer, with a white tick on a green disc. */
.sp-no-app {
    padding: 6px 14px 6px 6px;
    background: color-mix(in srgb, var(--sp-green) 15%, white);
    border: var(--sp-border) solid var(--sp-green);
}

.sp-no-app-tick {
    flex-shrink: 0;
}

.sp-no-app-tick circle {
    fill: var(--sp-green);
}

.sp-no-app-tick path {
    fill: none;
    stroke: white;
    stroke-width: 2.4px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Apple's App Store badge, unchanged and above the 40 px minimum. As wide as the badge wherever it stands, so only the
   badge is tapped, also in a flex column; the radius follows its corners for the focus ring. */
.sp-app-store {
    display: block;
    width: fit-content;
    border-radius: 8px;
}

.sp-app-store img {
    display: block;
    height: 48px;
    width: auto;
}

/* Google's badge beside Apple's, as tall as it: the PNG is 646 x 250 with the badge in rows 29 to 220, so the image is
   cut to the badge's 646 x 192 and the transparent margins fall outside. The badge itself is not changed. */
.sp-google-play {
    display: block;
    width: fit-content;
    border-radius: 8px;
}

.sp-google-play img {
    display: block;
    height: 48px;
    width: calc(48px * 646 / 192);
    object-fit: cover;
}

/* The start page's "Gör en egen runda" card, where the menu leads: not flush with the top of the screen. */
#gor-egen-runda {
    scroll-margin-top: 16px;
}

/* The menu in the top bar (SiteNav.razor). Line icons in the text's colour. */
.sp-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* From 768 px: the pages as links with icons; the current one with an orange icon and an orange line under it. */
.sp-nav {
    align-items: center;
    gap: 20px;
}

.sp-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 0;
    border-bottom: 3px solid transparent;
    color: var(--sp-dark);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.sp-nav-link:hover {
    color: var(--sp-dark);
    border-bottom-color: color-mix(in srgb, var(--sp-orange) 40%, transparent);
}

.sp-nav-link .sp-icon {
    width: 20px;
    height: 20px;
    color: color-mix(in srgb, var(--sp-dark) 55%, transparent);
}

.sp-nav-link.active {
    border-bottom-color: var(--sp-orange);
    font-weight: 800;
}

.sp-nav-link.active .sp-icon {
    color: var(--sp-orange);
    stroke-width: 2.4px;
}

/* Below 768 px: the "Meny" button, white with a dark border, dark while the menu is open. */
.sp-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px 8px 12px;
    border: var(--sp-border) solid var(--sp-dark);
    border-radius: 999px;
    background: white;
    color: var(--sp-dark);
    font-weight: 700;
}

.sp-menu-button.open {
    background: var(--sp-dark);
    color: white;
}

/* The menu over the whole page, under the cookie banner and the error bar; the page behind does not scroll. */
.sp-menu {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background-color: var(--sp-paper);
}

body:has(.sp-menu) {
    overflow: hidden;
}

.sp-menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: var(--sp-border) solid var(--sp-sand);
    color: var(--sp-dark);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: var(--sp-tight);
    text-decoration: none;
}

.sp-menu-arrow {
    margin-left: auto;
    color: color-mix(in srgb, var(--sp-dark) 45%, transparent);
}

.sp-icon-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--sp-sand);
    color: var(--sp-dark);
}

.sp-menu-link.active .sp-icon-tile {
    background: var(--sp-orange);
    color: white;
}

.sp-dot {
    width: 10px;
    height: 10px;
}

/* The QR code on the computer hand-off; the SVG scales to the box. */
.sp-qr {
    max-width: 240px;
}

.sp-qr svg {
    display: block;
    width: 100%;
    height: auto;
}

/* The finish: a green disc with a white tick on a dark offset shadow; sand with a dash when the round ended on the way.
   Fill and stroke in CSS, not as SVG attributes: var() in presentation attributes is not reliable in Safari. */
.sp-finish-mark {
    color: var(--sp-green);
}

.sp-finish-mark.ended {
    color: var(--sp-sand);
}

.sp-finish-mark .drop {
    fill: var(--sp-dark);
}

.sp-finish-mark .disc {
    stroke: var(--sp-dark);
    stroke-width: 2px;
}

.sp-finish-mark .sign {
    fill: none;
    stroke: white;
    stroke-width: 7px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sp-finish-mark.ended .sign {
    stroke: var(--sp-dark);
}

/* The creator's final message has a green border. */
.sp-final {
    --bs-card-border-color: var(--sp-green);
}

/* The standings and the facit on the finish page: white rows with a sand border; the team's own row has a dark
   left edge. The number of a stop sits in a small sand square, like the labels of the answer options. */
.sp-standing,
.sp-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: var(--sp-border) solid var(--sp-sand);
    border-radius: var(--sp-radius);
    background: white;
}

.sp-standing.own {
    border-inline-start: 6px solid var(--sp-dark);
}

.sp-result {
    align-items: flex-start;
}

.sp-result-number {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--sp-sand);
    font-size: 14px;
    font-weight: 800;
}

.sp-result-mark {
    flex: none;
    line-height: 0;
}

/* The pin on the location-denied page, and its how-to card: numbered steps in small sand squares. */
.sp-location-mark {
    stroke: var(--sp-orange);
    stroke-width: 2.2px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sp-howto-steps {
    list-style: none;
    counter-reset: step;
}

.sp-howto-steps li {
    display: flex;
    gap: 10px;
    counter-increment: step;
}

.sp-howto-steps li::before {
    content: counter(step);
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: var(--sp-sand);
    font-size: 11px;
    font-weight: 800;
}

/* "No connection" over every view of the round: a dark line that stays at the top while the page scrolls. */
.sp-offline {
    --bs-alert-color: white;
    --bs-alert-bg: var(--sp-dark);
    --bs-alert-border-color: var(--sp-dark);
    position: sticky;
    top: env(safe-area-inset-top, 0);
    z-index: 1020;
}

/* The privacy page: orange bullets, the retention table with thin sand lines, and the contents kept in view. */
.sp-dots {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sp-dots li {
    position: relative;
    padding-left: 20px;
}

.sp-dots li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sp-orange);
}

.sp-keep {
    --bs-table-bg: white;
    --bs-border-width: 1px;
    --bs-table-border-color: var(--sp-sand);
}

.sp-keep tr:last-child > * {
    border-bottom-width: 0;
}

.sp-keep th,
.sp-keep td {
    padding: 12px 16px;
    width: 50%;
}

/* Each contents link is a 44 px tap target; the height gives the spacing, so the list has no gap. */
.sp-toc a {
    display: flex;
    align-items: center;
    min-height: 44px;
}

@media (min-width: 768px) {
    .sp-toc {
        position: sticky;
        top: 24px;
    }
}

/* The boot screen in index.html until .NET has loaded. blazor.webassembly.js sets --blazor-load-percentage and
   --blazor-load-percentage-text on the root element; the box has a fixed width and "0%" before the first update,
   so nothing moves while the bar fills. */
.sp-boot {
    width: 100%;
    max-width: 320px;
}

.sp-boot .progress {
    --bs-progress-height: 10px;
    --bs-progress-border-radius: 5px;
}

.sp-boot-fill {
    width: var(--blazor-load-percentage, 0%);
}

.sp-boot-text {
    font-variant-numeric: tabular-nums;
}

.sp-boot-text::after {
    content: var(--blazor-load-percentage-text, "0%");
}

/* Blazor's error bar in index.html: hidden until Blazor sets display: block on it after an unhandled exception.
   Dark like the offline line, fixed to the bottom above the home indicator; the reload link is a 44 px target. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1080;
    padding: 0 16px env(safe-area-inset-bottom, 0);
    background: var(--sp-dark);
    color: white;
    font-weight: 600;
}

#blazor-error-ui .reload {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-left: 8px;
    color: white;
    font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* The cookie banner (CookieBanner.razor): fixed to the bottom, a card's width on wide screens, full width on phones. */
.sp-cookies {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    margin: 0 auto;
    max-width: 48rem;
}
