/* ── Australian Data Centre Map ────────────────────────────────────
   Editorial, not app-like. Paper ground, ink text, one alarm colour.
   No framework, no build step. Tokens first, then layout.
   ─────────────────────────────────────────────────────────────── */

:root {
  --paper:      #faf8f5;
  --paper-2:    #f2eee8;
  --rule:       #ddd6cc;
  --ink:        #14110f;
  --ink-2:      #4a443e;
  --ink-3:      #7a736a;

  --operational: #a4161a;
  --construction:#e07a1f;
  --proposed:    #b08900;
  --energy:      #3f3f46;
  --link:        #6d28d9;

  --focus:      #0b5fff;

  --panel-w:    22.5rem;
  --masthead-h: auto;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --shadow: 0 1px 2px rgba(20,17,15,.06), 0 6px 20px rgba(20,17,15,.08);
}

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

html, body { height: 100%; }
body {
  margin: 0;
  font: 400 16px/1.5 var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
}

a { color: var(--ink); text-decoration-color: var(--ink-3); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--operational); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem;
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* ── Masthead ───────────────────────────────────────────────────── */

/* Body is a flex column. Everything that is not the map must refuse to shrink,
   or the map's min-height squashes it and paints over the overflow. */
.masthead, .banner, .colophon { flex: none; }

.masthead {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2rem;
  padding: 1rem 1.25rem .9rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.masthead__title { flex: 1 1 22rem; min-width: 0; }
.masthead h1 {
  margin: 0;
  font: 600 clamp(1.25rem, 1rem + 1.1vw, 1.75rem)/1.15 var(--serif);
  letter-spacing: -.015em;
}
.masthead__sub {
  margin: .3rem 0 0; max-width: 62ch;
  font-size: .875rem; color: var(--ink-2);
}
.masthead__counts { display: flex; gap: 1.5rem; margin: 0; flex-wrap: wrap; }
.masthead__counts div { display: flex; flex-direction: column-reverse; }
.masthead__counts dt {
  font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.masthead__counts dd {
  margin: 0; font: 600 1.375rem/1 var(--sans); font-variant-numeric: tabular-nums;
}
.masthead__counts div:nth-child(1) dd { color: var(--operational); }
.masthead__counts div:nth-child(2) dd { color: var(--construction); }
.masthead__counts div:nth-child(3) dd { color: var(--proposed); }
.masthead__counts div:nth-child(4) dd { color: var(--energy); }

.banner {
  margin: 0; padding: .6rem 1.25rem;
  background: #fff6d8; border-bottom: 1px solid #e3cf8a;
  font-size: .8125rem; color: #5c4a05;
}

/* ── Shell: panel + map ─────────────────────────────────────────── */

.shell { flex: 1 1 auto; display: flex; min-height: 0; position: relative; overflow: hidden; }

#map { flex: 1 1 auto; min-height: 0; background: var(--paper-2); }
#map:focus-visible { outline-offset: -3px; }

.panel {
  flex: 0 0 var(--panel-w); width: var(--panel-w);
  border-right: 1px solid var(--rule);
  background: var(--paper);
  overflow-y: auto; overscroll-behavior: contain;
}
.panel__handle { display: none; }
.panel__body { padding: .25rem 0 2rem; }

.control { padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); }
.control:last-child { border-bottom: 0; }
.control__h {
  margin: 0 0 .65rem;
  font: 600 .6875rem/1 var(--sans); letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3);
}
.control__note { margin: .5rem 0 0; font-size: .75rem; color: var(--ink-3); line-height: 1.45; }

/* Search */
.search { display: flex; gap: .4rem; }
.search input {
  flex: 1 1 auto; min-width: 0;
  padding: .5rem .6rem; font: inherit; font-size: .875rem;
  border: 1px solid var(--rule); border-radius: 3px; background: #fff; color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }

/* Buttons */
.btn {
  font: 600 .8125rem/1 var(--sans); border-radius: 3px; cursor: pointer;
  padding: .55rem .8rem; border: 1px solid transparent;
}
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: #2b2521; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { border-color: var(--ink-3); }
.btn--block { display: block; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkish {
  background: none; border: 0; padding: 0; font: inherit; color: var(--ink);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* Layers */
.layers { list-style: none; margin: 0; padding: 0; }
.layers__rule { height: 1px; background: var(--rule); margin: .55rem 0; }
.layer {
  display: grid; grid-template-columns: 1rem 1.1rem 1fr auto;
  align-items: center; gap: .55rem;
  padding: .3rem 0; cursor: pointer; font-size: .875rem;
}
.layer:hover .layer__name { text-decoration: underline; text-underline-offset: 2px; }
.layer input { margin: 0; accent-color: var(--ink); width: 1rem; height: 1rem; }
.layer__count { font: 500 .75rem/1 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.layer:has(input:disabled) { cursor: not-allowed; }
.layer:has(input:disabled) .swatch,
.layer:has(input:disabled) input { opacity: .35; }
.layer--unavailable .layer__name { color: var(--ink-3); }
.layer--unavailable .layer__count {
  font: 400 .6875rem/1 var(--sans); letter-spacing: .01em; color: var(--ink-3); font-style: italic;
}
.layer--unavailable:hover .layer__name { text-decoration: none; }

.swatch { width: 1.1rem; height: 1.1rem; display: inline-block; }
.swatch--operational  { border-radius: 50%; background: var(--operational); }
.swatch--construction { border-radius: 50%; background: var(--construction); }
.swatch--proposed     { border-radius: 50%; background: transparent; border: 2px dashed var(--proposed); }
.swatch--energy       { background: var(--energy); transform: rotate(45deg) scale(.8); }
.swatch--link         { height: 0; border-top: 2px dashed var(--link); }
.swatch--drought      { background: linear-gradient(90deg, #efe0c4, #b07a3a); border-radius: 2px; }

/* Drought ramp */
.ramp { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.ramp li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .55rem; align-items: center; font-size: .8125rem; }
.ramp i { display: block; height: 1.1rem; border-radius: 2px; }

/* Reading notes.
   Each <li> must hold exactly two children — the swatch and one wrapping <span>.
   Loose text nodes and inline <strong> become their own grid items and the
   whole list shreds into columns. */
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; font-size: .8125rem; color: var(--ink-2); }
.notes li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .55rem; align-items: start; line-height: 1.45; }
.notes li.notes__full { grid-template-columns: 1fr; padding-top: .45rem; border-top: 1px solid var(--rule); margin-top: .2rem; }
.dot { width: 1.1rem; height: 1.1rem; margin-top: .1rem; flex: none; }
.dot--hollow  { border-radius: 50%; border: 2px dashed var(--proposed); }
.dot--halo    { border-radius: 50%; border: 1px dashed var(--operational);
                background: radial-gradient(var(--operational) 0 32%, transparent 33%); }
.dot--diamond { background: var(--energy); transform: rotate(45deg) scale(.8); }
.dot--size    { border-radius: 50%; background: var(--operational); opacity: .8;
                box-shadow: -.45rem 0 0 -.28rem var(--operational); transform: scale(.85); }

/* ── Markers ────────────────────────────────────────────────────── */

.marker-diamond {
  background: var(--energy); transform: rotate(45deg);
  border: 1.5px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35);
  display: grid; place-items: center;
}
.marker-diamond span {
  transform: rotate(-45deg);
  color: #fff; font: 700 9px/1 var(--sans); letter-spacing: .02em;
}
.marker-diamond--proposed { background: #fff; border: 2px dashed var(--energy); }
.marker-diamond--proposed span { color: var(--energy); }

/* ── Popups ─────────────────────────────────────────────────────── */

.leaflet-popup-content-wrapper { border-radius: 4px; box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 0; width: 20rem !important; max-width: 78vw; }
.leaflet-container { font-family: var(--sans); }

.pop { font-size: .8125rem; color: var(--ink); }
.pop__head { padding: .8rem .9rem .6rem; border-bottom: 1px solid var(--rule); }
.pop__tag {
  display: inline-block; margin-bottom: .35rem; padding: .18rem .4rem;
  font: 700 .625rem/1 var(--sans); letter-spacing: .07em; text-transform: uppercase;
  color: #fff; border-radius: 2px;
}
.pop__tag--operational  { background: var(--operational); }
.pop__tag--construction { background: var(--construction); }
.pop__tag--proposed     { background: var(--proposed); }
.pop__tag--energy       { background: var(--energy); }
.pop__name { margin: 0; font: 600 1.0625rem/1.25 var(--serif); }
.pop__op   { margin: .2rem 0 0; color: var(--ink-2); }

.pop__body { padding: .7rem .9rem; }
.pop__facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .3rem .7rem; }
.pop__facts dt { color: var(--ink-3); font-size: .75rem; }
.pop__facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.pop__facts dd small { display: block; color: var(--ink-3); font-size: .6875rem; line-height: 1.35; }

.pop__conf {
  margin: .7rem 0 0; padding: .45rem .55rem; border-radius: 3px; font-size: .75rem;
  background: var(--paper-2); color: var(--ink-2); border-left: 3px solid var(--rule);
}
.pop__conf--uncertain { background: #fff6d8; border-left-color: #d6b34a; color: #5c4a05; }
.pop__conf b { font-weight: 600; }

.pop__notes { margin: .6rem 0 0; color: var(--ink-2); }

.pop__links { margin: .6rem 0 0; padding: 0; list-style: none; display: grid; gap: .35rem; }
.pop__links li { font-size: .75rem; line-height: 1.4; }
.pop__links a { display: inline; }
.pop__links .kind {
  display: inline-block; margin-right: .35rem; padding: .05rem .3rem;
  font: 700 .5625rem/1.5 var(--sans); text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid var(--rule); border-radius: 2px; color: var(--ink-3);
}
.pop__links .kind--primary { color: #14532d; border-color: #9ccdae; background: #eef7f1; }

.pop__foot {
  padding: .55rem .9rem .7rem; border-top: 1px solid var(--rule);
  font-size: .6875rem; color: var(--ink-3);
}
.pop__foot a { color: var(--ink-3); }

/* ── Colophon ───────────────────────────────────────────────────── */

.colophon {
  display: flex; flex-wrap: wrap; gap: .3rem 1.5rem;
  padding: .55rem 1.25rem; border-top: 1px solid var(--rule);
  font-size: .75rem; color: var(--ink-3); background: var(--paper);
}
.colophon p { margin: 0; }

/* ── Modals ─────────────────────────────────────────────────────── */

.modal {
  border: 0; border-radius: 5px; padding: 0; max-width: 40rem; width: calc(100vw - 2rem);
  max-height: calc(100dvh - 3rem); box-shadow: 0 12px 48px rgba(20,17,15,.28);
  background: var(--paper); color: var(--ink);
}
.modal::backdrop { background: rgba(20,17,15,.45); }
.modal__close-form { position: sticky; top: 0; height: 0; z-index: 2; }
.modal__close {
  position: absolute; right: .5rem; top: .5rem;
  width: 2rem; height: 2rem; border: 0; border-radius: 50%;
  background: var(--paper-2); color: var(--ink); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.modal__close:hover { background: var(--rule); }
.modal__body { padding: 1.5rem 1.6rem 1.75rem; overflow-y: auto; max-height: calc(100dvh - 3rem); }
.modal__body h2 { margin: 0 0 .75rem; font: 600 1.4rem/1.2 var(--serif); }
.modal__body h3 { margin: 1.4rem 0 .35rem; font: 600 .8125rem/1.2 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.modal__body p { margin: 0 0 .7rem; font-size: .9375rem; max-width: 62ch; }
.modal__meta { margin-top: 1.5rem; padding-top: .8rem; border-top: 1px solid var(--rule); font-size: .75rem; color: var(--ink-3); }

/* Form */
.field { margin: 0 0 1rem; }
.field label, .field legend { display: block; margin-bottom: .3rem; font-size: .8125rem; font-weight: 600; }
.field--contact { border: 1px solid var(--rule); border-radius: 4px; padding: .8rem .9rem; }
.field--contact label { margin-top: .6rem; font-weight: 400; }
.field--contact legend { padding: 0 .35rem; }
.req { font-weight: 400; color: var(--ink-3); font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select, .field textarea {
  width: 100%; padding: .5rem .6rem; font: inherit; font-size: .875rem;
  border: 1px solid var(--rule); border-radius: 3px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 5.5rem; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"], .field select[aria-invalid="true"] {
  border-color: var(--operational); background: #fff7f7;
}
.field__hint { margin: .3rem 0 0; font-size: .75rem; color: var(--ink-3); line-height: 1.45; }
.check { display: flex; gap: .5rem; align-items: flex-start; margin-top: .7rem; font-weight: 400; font-size: .8125rem; }
.check input { width: auto; margin-top: .15rem; }
.hp { position: absolute; left: -9999px; }
.form-status { margin: 0 0 .6rem; font-size: .8125rem; }
.form-status[data-tone="error"] { color: var(--operational); }
.form-status[data-tone="ok"] { color: #14532d; }

/* ── Mobile ─────────────────────────────────────────────────────── */

@media (max-width: 52rem) {
  .shell { flex-direction: column-reverse; }
  /* The map takes what is left after the panel, rather than claiming a fixed
     slice — a tall open panel must never push the map out of the shell. */
  #map { flex: 1 1 auto; min-height: 10rem; }

  .panel {
    flex: 0 1 auto; width: 100%;
    border-right: 0; border-top: 1px solid var(--rule);
    max-height: 45dvh;
  }
  .panel__handle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: .75rem 1.25rem; cursor: pointer;
    background: var(--paper-2); border: 0; border-bottom: 1px solid var(--rule);
    font: 600 .8125rem/1 var(--sans); color: var(--ink);
    position: sticky; top: 0; z-index: 2;
  }
  .panel__chev {
    width: .5rem; height: .5rem; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
    transform: rotate(-135deg); transition: transform .15s;
  }
  .panel__handle[aria-expanded="false"] .panel__chev { transform: rotate(45deg); }
  .panel__body[hidden] { display: none; }

  /* On a phone the map is the story — every row of chrome above it is a row of
     map the reader does not get. Counts go to one tight line of four. */
  .masthead { padding: .7rem 1rem .6rem; gap: .55rem 1rem; align-items: center; }
  .masthead__title { flex: 1 1 100%; }
  .masthead h1 { font-size: 1.1875rem; }
  .masthead__sub { font-size: .78125rem; margin-top: .15rem; }
  .masthead__counts { flex: 1 1 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
  .masthead__counts dt { font-size: .5625rem; letter-spacing: .04em; line-height: 1.15; }
  .masthead__counts dd { font-size: 1.0625rem; }
  .masthead__about { flex: 0 0 auto; padding: .45rem .6rem; font-size: .75rem; }
  .banner { padding: .5rem 1rem; font-size: .75rem; }
  .modal__body { padding: 1.25rem 1.1rem 1.5rem; }
  .leaflet-popup-content { width: 17rem !important; }
}

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

@media print {
  .panel, .colophon, .masthead__about, .banner { display: none; }
  #map { height: 80vh; }
}
