/* Driving-school finder (#/schools) and the municipality maps — see web/app/schools.js,
   web/app/glmap.js and docs/schools.md. Colours are tokens from styles.css :root, including
   the MapLibre overrides at the bottom, so its chrome follows the dark theme. */

/* No width override any more: .view is --page-w (1160px) on every route, and the
   map column sizes itself inside it. The old body.schools cap (1240px) was 80px
   wider than the landing page and made #/schools the one route whose content did
   not line up with the rest of the site. */

.schoolintro { margin-bottom: 1rem; }

.schoolwrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.1rem;
  align-items: start;
}

/* The search bar sits *over* the map on desktop (the finder's whole premise is a big
   map you type into), and above it on narrow screens where an overlay would cover a
   third of the visible map. One DOM order, two positions. */
.schoolmain { position: relative; }
.schoolhead { position: absolute; z-index: 700; top: .9rem; left: .9rem; right: .9rem; max-width: 30rem; }
.schoolhead .searchbar { margin-bottom: .55rem; }
/* A floating control has to stay readable over whatever the map happens to show under
   it, so the field is opaque-ish glass with a real elevation rather than a flat box. */
.schoolhead .searchbar input {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px) saturate(1.1);
  border-radius: var(--r-pill);
  border-color: color-mix(in srgb, var(--text) 10%, transparent);
  padding: .8rem 1rem .8rem 2.6rem;
  box-shadow: var(--shadow-lg);
  font-size: .96rem;
}
.schoolhead .searchbar input::placeholder { color: var(--muted); }
@media (max-width: 560px), (pointer: coarse) { .schoolhead .searchbar input { font-size: 16px; } }   /* iOS focus-zoom floor */
.schoolhead .searchbar svg { left: 1rem; z-index: 1; }   /* the input's backdrop-filter stacks it over the icon */
.schoolchips { display: flex; gap: .4rem; flex-wrap: wrap; }
.schoolchips .chip {
  display: inline-flex; align-items: center; gap: .35rem;
  box-shadow: var(--shadow-lg);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px) saturate(1.1);
  border-color: color-mix(in srgb, var(--text) 10%, transparent);
  font-weight: 600;
}
.schoolchips .chip svg { width: 1rem; height: 1rem; }
.schoolchips .chip.is-busy { opacity: .7; cursor: progress; }
/* Both floating controls above sit at 92% fill over a live map, so they are the one place
   on this route where the reader's transparency/contrast preference changes legibility
   rather than taste: the remaining 8% is map tiles showing through a search field. Solid
   fill, real border, no blur. */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .schoolhead .searchbar input, .schoolchips .chip {
    background: var(--surface); border-color: var(--border); backdrop-filter: none;
  }
}
/* The ?kommune= scope chip. Filled rather than outlined, because it is not an action
   the reader can take — it is state they arrived in, and the ✕ is how they leave it. */
.schoolchips .chip.is-scope {
  background-color: var(--grad-solid); background-image: var(--grad-ui);
  color: var(--brand-ink); border-color: transparent;
}
.schoolchips .chip.is-scope svg { width: .9rem; height: .9rem; opacity: .8; }
.schoolchips .chip.is-scope:hover { filter: brightness(1.06); }

.schoolmap-shell { position: relative; }
.schoolmap {
  height: min(72vh, 700px);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
/* A hairline inside the rounded corner: reads as inset glass rather than a flat
   rectangle, and keeps the map edge crisp where tiles meet the border radius. */
.schoolmap-shell::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border-radius: var(--r-xl);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
}

@media (min-width: 861px) {
  .schoolmain { position: sticky; top: 4.75rem; }
}

/* The tiles-down notice (MapLibre shows its own Ctrl/⌘-to-zoom hint). */
.schoolzoomhint {
  position: absolute; inset: auto 0 1rem 0; margin: 0 auto; width: fit-content;
  padding: .4rem .8rem; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); font-size: .82rem;
  opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
  pointer-events: none; z-index: 700;
}
.schoolzoomhint.is-on { opacity: 1; }

.schoolside { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.schoolcount {
  margin: 0; font-size: .82rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.schoolrows {
  display: flex; flex-direction: column; gap: .5rem;
  max-height: min(72vh, 700px); overflow-y: auto;
  /* Leaves room for the scrollbar so hover doesn't shift the rows sideways. */
  padding-right: .2rem;
}
.schoolmore, .schoolsource { margin: .2rem 0 0; font-size: .8rem; }

.schoolrow {
  position: relative; overflow: hidden;
  /* The rows live in a fixed-height flex column, so without this they shrink to fit
     and the name collides with the address instead of the list scrolling. */
  flex: 0 0 auto;
  display: flex; align-items: center; gap: .6rem; justify-content: space-between;
  padding: .75rem .9rem .75rem 1rem; text-decoration: none; color: inherit;
  transition: border-color var(--dur-quick) var(--ease-out),
              transform var(--dur-quick) var(--ease-out),
              box-shadow var(--dur-quick) var(--ease-out);
}
/* An accent rail that grows in on hover and stays for the selected row — the one place
   the list needs a strong "this is the pin you're looking at" signal. */
.schoolrow::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background-image: var(--grad-ui); background-color: var(--grad-solid);
  transform: scaleY(0); transform-origin: center;
  transition: transform var(--dur-quick) var(--ease-out);
}
.schoolrow:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); transform: translateY(-1px); box-shadow: var(--shadow); }
.schoolrow:hover::before { transform: scaleY(1); }
.schoolrow.is-active { border-color: var(--brand); box-shadow: var(--shadow); }
.schoolrow.is-active::before { transform: scaleY(1); }
.schoolrow-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.schoolrow-name { font-size: .95rem; line-height: 1.25; }
.schoolrow-addr { font-size: .82rem; }
.schoolrow-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex-shrink: 0; }
.schoolrow-dist { font-size: .82rem; font-weight: 700; color: var(--brand); white-space: nowrap; }


/* ---------------------------------------------------------------- detail page */
/* `.schoolback` (the one-way "back to results" link) is now the shared `.crumbs` trail
   in styles.css, which keeps the same query-preserving href and adds Home in front. */
.schooldetail { display: flex; flex-direction: column; gap: .9rem; }
.schooldetail-head h1 { margin-bottom: .35rem; }
.schooltags { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0; }
.schoolcard { display: flex; flex-direction: column; gap: .6rem; border-radius: var(--r-lg); }
.schoolh2 {
  font-size: .78rem; margin: 0; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.schooladdr { margin: 0; font-size: 1.05rem; line-height: 1.45; }
.schoolnote { margin: 0; font-size: .82rem; line-height: 1.5; }
.schoolminimap {
  height: 240px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface-2); overflow: hidden; box-shadow: var(--shadow);
}
.schoolacts { display: flex; gap: .5rem; flex-wrap: wrap; }
.schoolact { display: inline-flex; align-items: center; gap: .4rem; }
.schoolact svg { width: 1.05rem; height: 1.05rem; }
.schoolfacts {
  display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem;
  margin: 0; font-size: .9rem;
}
.schoolfacts dt { color: var(--muted); }
.schoolfacts dd { margin: 0; }

/* ------------------------------------------------------------------ narrow */
/* Phones: the map fills the screen and the list is a sheet pulled up over it (schools.js setSheet),
   like the Google Maps app. Three rests; a drag sets --sheet-drag live, release snaps. */
.sheet-handle { display: none; }
@media (max-width: 860px) {
  .schoolintro .lead { display: none; }
  .schoolwrap { display: block; position: relative; }
  .schoolhead { position: static; margin-bottom: .7rem; max-width: none; }
  .schoolhead .searchbar { box-shadow: none; }
  .schoolmap { height: calc(100dvh - 12.5rem); min-height: 420px; }
  .schoolside {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
    height: var(--sheet-drag, var(--sheet-h, 7.5rem)); gap: .4rem;
    padding: 0 .8rem .6rem; border-radius: 22px 22px var(--r-xl) var(--r-xl);
    background: var(--surface); border: 1px solid var(--border); box-shadow: 0 -8px 30px rgba(15, 23, 42, .18);
    overflow: hidden; transition: height .32s cubic-bezier(.2, .8, .2, 1);
  }
  .schoolside.is-dragging { transition: none; }
  .schoolside[data-sheet="peek"] { --sheet-h: 7.5rem; }
  .schoolside[data-sheet="half"] { --sheet-h: 52%; }
  .schoolside[data-sheet="full"] { --sheet-h: calc(100% - 3rem); }
  .sheet-handle { display: grid; place-items: center; width: 100%; height: 1.6rem; flex: none; padding: 0;
    background: none; border: 0; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 2.6rem; height: 5px; border-radius: 3px; background: var(--border); }
  .schoolcount { touch-action: none; cursor: grab; }
  .schoolrows { max-height: none; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
  .schoolside[data-sheet="peek"] .schoolrows { overflow: hidden; }
  .schoolsource { display: none; }
  .schoolzoomhint { bottom: 8.5rem; }
}
@media (max-width: 560px) {
  .schoolrow { padding: .65rem .7rem; }
  .schoolact { flex: 1 1 8rem; justify-content: center; }
}

/* Map easings ignore the media query; ours must not. */
@media (prefers-reduced-motion: reduce) {
  .schoolrow, .schoolzoomhint { transition: none; }
  .schoolrow:hover { transform: none; }
  .schoolrow::before { transition: none; }
}

/* ------------------------------------------------------------ MapLibre (#/schools) */
/* The chrome MapLibre ships (controls, popup, attribution) re-tokenised for both themes. */
.maplibregl-map { font: inherit; }
.schoolmap .maplibregl-ctrl-group { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; }
.schoolmap .maplibregl-ctrl-group button + button { border-top-color: var(--border); }
.schoolmap .maplibregl-ctrl-group button:hover { background-color: var(--surface-2); }
:root[data-theme="dark"] .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); font-size: .68rem; }
.maplibregl-ctrl-attrib a { color: var(--brand); }
.maplibregl-cooperative-gesture-screen { font: inherit; font-weight: 650; }

/* The selected (and list-hovered) school: a bigger pin above the symbol layer. */
.glpin { width: 34px; height: 46px; cursor: pointer; filter: drop-shadow(0 4px 6px rgba(15, 23, 42, .35)); }
.glpin svg { display: block; width: 100%; height: 100%; }
.glpin path { fill: var(--brand); stroke: #fff; stroke-width: 2; }
.glpin circle { fill: #fff; }
.glpin.is-active { width: 40px; height: 54px; animation: glpin-drop .35s cubic-bezier(.2, 1.4, .4, 1); }
.glpin.is-hover { opacity: .9; }
.glpin.is-hover path { fill: var(--blue); }
@keyframes glpin-drop { from { transform: translateY(-14px) scale(.8); opacity: .4; } }
.glyou { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 3px solid #fff;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--blue) 25%, transparent), 0 2px 6px rgba(0, 0, 0, .3); }

/* The info card. */
.schoolpop .maplibregl-popup-content { background: var(--surface); color: var(--text); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: .9rem 1rem .8rem; border: 1px solid var(--border); }
.schoolpop.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface); }
.schoolpop.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.schoolpop.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.schoolpop.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.schoolpop .maplibregl-popup-close-button { color: var(--muted); font-size: 1.2rem; width: 2rem; height: 2rem; border-radius: 50%; }
.schoolpop .maplibregl-popup-close-button:hover { background: var(--surface-2); }
.spop { display: grid; gap: .3rem; padding-right: 1.2rem; }
.spop-name { font-size: 1rem; line-height: 1.3; }
.spop-addr { color: var(--muted); font-size: .86rem; }
.spop-dist { color: var(--brand); font-weight: 700; font-size: .84rem; }
.spop-acts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.spop-acts .btn { display: inline-flex; align-items: center; gap: .3rem; }
.spop-acts svg { width: .95rem; height: .95rem; }
.spop-more { font-size: .84rem; font-weight: 650; margin-top: .2rem; }

/* "Søk i dette området": offered after the reader moves the map. */
/* Centred with `translate`, not `transform`: the shared .chip:hover lift sets `transform`, and
   overriding it made the button jump sideways under the pointer. */
.schoolarea { position: absolute; z-index: 6; top: .9rem; left: 50%; translate: -50% 0;
  display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; box-shadow: var(--shadow-lg);
  background: var(--surface); border-color: var(--border); }
.schoolarea svg { width: 1rem; height: 1rem; }
.schoolarea[hidden] { display: none; }
@media (min-width: 861px) { .schoolarea { top: auto; bottom: 2.6rem; } }
@media (prefers-reduced-motion: reduce) { .schoolside, .glpin.is-active { transition: none; animation: none; } }

/* No boxes (owner 2026-10-01), same treatment as the city SEO pages: the result list is hairline rows
   (the red rail still marks hover / the selected pin), and the school page's cards are plain sections
   split by hairlines. The phone sheet keeps its panel — it floats over the map and needs a ground. */
.schoolrows { gap: 0; }
.schoolrow.card, .schoolrow.card:hover, .schoolrow.card.is-active {
  background: none; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  box-shadow: none; outline: 0; transform: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.schoolrow.card:hover .schoolrow-name, .schoolrow.card.is-active .schoolrow-name { color: var(--brand); }
.schooldetail .card.schoolcard {
  background: none; border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none;
  outline: 0; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 1rem 0 0; }
