:root {
  --bg: #0b1b2b;
  --card: #ffffff;
  --muted: #f6f8fb;
  --text: #1c2733;
  --accent: #0ea5e9;
  --header-h: 64px;
  --ok: #0ea5e9;
  --warn: #dc2626;
  --logo-h: 48px;
  --logo-w-min: 80px;
  --logo-w-pref: 18vw;
  --logo-w-max: 140px;
  --logo-scale: 1;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  background: var(--muted);
  color: var(--text);
}
/* HEADER: left title, right logos, footprints scaled to header height */
header{
  /* spacing + min height */
  padding: .75rem 1.25rem;
  min-height: 75px;

  /* flex layout */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;

  /* gradient + footprints image (two background layers) */
  background:
	url('header-footprints.png'),
    radial-gradient(circle,rgba(67, 79, 117, 1) 0%, rgba(52, 58, 89, 1) 100%);
  background-repeat:  repeat-x, no-repeat;
  background-position: center center, center center;
  /* gradient covers header, footprints scale to header height */
  background-size: auto 60%, cover;

  color:#fff;
}

header h1{
  margin:0;
  font-size:1.15rem;
  line-height:1.2;
  /* prevent logos from squashing the title on small screens */
  flex: 1 1 auto;
  text-transform: uppercase;
}

/* Right side: logo links container */
header .logos{
  display:flex;
  align-items:center;
  gap:.75rem;
  /* keep logos from wrapping under the title; let them shrink a bit if needed */
  flex: 0 1 auto;
}

/* Individual logo links (background images) */
header .logo{
  display:block;
  height: calc(var(--logo-h) * var(--logo-scale));
  width: clamp(
    calc(var(--logo-w-min) * var(--logo-scale)),
    calc(var(--logo-w-pref) * var(--logo-scale)),
    calc(var(--logo-w-max) * var(--logo-scale))
  );
  background-repeat:no-repeat;
  background-position:center center;
  background-size:contain;
  text-indent:-9999px; overflow:hidden;
  float:none;
}

/* Existing per-logo images (keep your filenames) */
header .logo.ruahine{ background-image:url('nga-ruahine-logo-full.png'); }
header .logo.ruanui{ background-image:url('ngati-ruanui-logo-full.png'); }
header .logo.motu  { background-image:url('nga-motu-logo-small.png'); }
header .logo.gps   { background-image:url('gps-logo-full.png'); }

@media (max-width: 900px){
	header { border-bottom: 1px solid #888; }
	:root{ --logo-scale: .9; }
	header .logos{ gap: .6rem; }
	header .logo.ruahine{ background-image:url('nga-ruahine-logo-small.png'); }
	header .logo.ruanui{ background-image:url('ngati-ruanui-logo-small.png'); }
	header .logo.gps    { background-image:url('gps-logo-small.png'); }
}

/* Small screens: slightly smaller logos / title */
@media (max-width: 560px){
  header h1{ font-size:1rem; }
  :root{ --logo-scale: .8; } /* or .75 if you want them even smaller */
}

/* Full-viewport app frame */
.app {
  height: calc(100vh - var(--header-h));
  padding: 1rem;
}

/* Two-pane responsive layout */
.layout {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(340px, 420px);
  gap: 1rem;
}
@media (max-width: 900px) {
  .app {
    height: auto;
  }
  .layout {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Map pane fills available height; no grey gutters */
.map-pane {
  min-height: 300px;
}
#map {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
}

@media (max-width: 900px){
  .app{ padding: 0; }     /* drop the page gutters */
  .layout{ gap: 0; }      /* no gap around the map card */
  .map-pane{
    border-radius: 0;
    box-shadow: none;
  }
  #map{ border-radius: 0; }
}

@media (max-width: 900px){
  /* Make the map nice and tall on phones */
  #map{
    height: 40svh; /* try 70–75svh to taste */
  }

  /* Keep the hint tucked under the map */
  .map-instructions{
    margin: 0 1rem .5rem; /* match your page padding */
  }
}

/* Form pane scrolls if needed, keeping header visible */
.form-pane {
  padding: 1rem;
  overflow: auto;
}
.row {
  display: flex;
  gap: 0.75rem;
}
.row > * {
  flex: 1;
  min-width: 0;
}
label {
  display: block;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
}
input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
textarea {
  min-height: 100px;
  resize: vertical;
}
.muted {
  color: #5b6b7a;
  font-size: 0.9rem;
}
.coords {
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  background: #f1f5f9;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-top: 0.5rem;
}
@media (max-width: 900px){
  /* Hide the coords row below the form */
  .coords, .locError{ display: none; }
  
}

/* Button: full width, nice transitions */
.btn{
  display:block;
  width:100%;
  appearance:none;
  border:none;
  border-radius:10px;
  padding:.9rem 1rem;
  font-weight:700;
  cursor:pointer;
  transition: background-color .2s ease, box-shadow .2s ease, transform .02s linear, opacity .2s ease;
  box-shadow:0 6px 14px rgba(0,0,0,.12);
  color:#fff;
}

/* State driven purely by data attribute */
.btn[data-state="invalid"]{ background: var(--warn); }
.btn[data-state="ready"]  { background: var(--ok); }

.btn[disabled]{ opacity:.85; cursor:not-allowed; }

/* Action block */
.actions { 
	margin-top:.9rem; 
}
.actions .help-text { 
	margin:.5rem 0 0; text-align:center; 
}

@media (max-width: 900px){
  /* Make the submit bar fixed to the viewport bottom */
  .actions{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0; /* override the -1rem trick */
    padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -6px 14px rgba(16,24,40,.10);
    z-index: 9999;
  }

  /* Ensure the last inputs aren't hidden behind the fixed bar */
  .form-pane{
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
    overflow: visible; /* allow the inner fixed bar to be fully visible */
  }
}

/* Desktop: make the submit button span the full form width */
@media (min-width: 901px){
  .actions{
    display: block;           /* stop flex from constraining width */
    margin-top: .9rem;        /* keep your spacing */
    padding: 0;               /* ensure no odd insets */
  }
  .actions .btn{
    display: block;
    width: 100%;
    max-width: none;
    flex: 1 1 100%;           /* harmless if parent is flex */
    align-self: stretch;      /* harmless if parent is not flex */
  }
}


.errors {
  background: #fff0f0;
  color: #9a1a1a;
  border: 1px solid #ffd6d6;
  padding: 0.75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 0.75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.errline {
  color: #b91c1c;
  font-size: 0.9rem;
  margin-top: 0.4rem;
  display: none;
}
.errline.show {
  display: block;
}

.map-instructions{
  padding: .2rem;
  font-size: .6rem;
  color: #5b6b7a;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  text-align: center;
  margin-bottom: 0;
}

/* Link-styled button for touch "Remove pin" */
.link-btn{
  background: none;
  border: none;
  padding: 0 .25rem;
  color: var(--ok, #0ea5e9);
  font-weight: 600;
  cursor: pointer;
}
.link-btn[hidden]{ display: none; }

/* Label row: keep icon right next to the label text */
.label-row{
  display: inline-flex;        /* shrink to content width */
  align-items: center;
  justify-content: flex-start; /* no push to panel edge */
  gap: .35rem;                 /* small space between label and icon */
  margin-bottom: .25rem;
}

/* Compact icon button */
.icon-btn{
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  vertical-align: middle;
}

/* Smaller icon */
.icon-btn img{
  width: 16px;
  height: 16px;
  display: block;
}

/* Slightly larger tap target on small screens */
@media (max-width: 560px){
  .icon-btn img{
    width: 20px;
    height: 20px;
  }
}

/* Ensure modal media scales nicely */
.placeholder{
  height: 180px;               /* keep a tidy box */
  border: 1px dashed #bbb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f7f7;
  overflow:hidden;
}
.placeholder img{
  width: 100%;
  object-fit: contain;
  display: block;
  cursor: pointer;
}
.placeholder audio{
  width: 100%;
}

/* Simple modal styles (native <dialog>) */
dialog.modal{
  border:none;
  border-radius:12px;
  padding:1rem 1.2rem;
  width:min(92vw, 640px);
  max-width:640px;
  box-shadow:0 12px 34px rgba(0,0,0,.25);
}
dialog.modal::backdrop{
  background:rgba(0,0,0,.55);
}

.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  gap:.75rem; margin-bottom:.5rem;
}
.modal-head h2{ font-size:1.15rem; margin:0; }
.close-btn{
  background:whitesmoke; border:0; font-size:1.5rem; line-height:1;
  cursor:pointer; padding:.25rem .5rem; border-radius:1rem;
}
.close-btn:hover{ background:rgba(0,0,0,.06); }

.modal-body{ display:grid; gap:1rem; }
.modal-section h3{ 
	margin:.25rem 0 .5rem; 
	font-size:1rem; 
	overflow: hidden;
}

/* ---- Lightbox dialog ---- */
dialog.modal.lightbox{
  border: 0;
  padding: 0;
  margin: 0;
  width: 100vw;                /* full viewport (fallback) */
  height: 100vh;
  max-width: none;
  background: transparent;
}
dialog.modal.lightbox::backdrop{
  background: rgba(0,0,0,.85);
}

/* Use safe-area aware padding so nothing is clipped on phones */
.lightbox-body{
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* small margins + safe areas on all sides */
  padding:
    max(6px, env(safe-area-inset-top))
    max(6px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom))
    max(6px, env(safe-area-inset-left));
}

/* Frame wraps the image so we can pin the close button on it */
.lightbox-frame{
  position: relative;
  margin: 0;
  line-height: 0;
  /* width clamps to viewport minus padding; caps at 1200px on desktop */
  max-width: 1200px;
  width: 100%;
}

/* Image always fits the available width; height contained to viewport */
.lightbox-frame img{
  display: block;
  width: 100%;                                 /* key: no sideways overflow */
  height: auto;
  max-height: calc(100dvh - 12px
                   - env(safe-area-inset-top)
                   - env(safe-area-inset-bottom));
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  object-fit: contain;                         /* no cropping */
}

/* Round white close button over the image (top-right) */
dialog.modal.lightbox .close-btn{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 9999px;
  background: #fff;
  color: #111;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
dialog.modal.lightbox .close-btn:hover{ background: #f2f2f2; }

/* Phone tweaks: slightly tighter margins */
@media (max-width: 600px){
  .lightbox-body{
    padding:
      max(4px, env(safe-area-inset-top))
      max(4px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(4px, env(safe-area-inset-left));
  }
  dialog.modal.lightbox .close-btn{
    top: 8px; right: 8px; width: 36px; height: 36px; font-size: 20px;
  }
}



/* Make the preview images look clickable */
#obsInfoDialog .placeholder{ cursor: zoom-in; overflow: hidden; }
#obsInfoDialog .placeholder img{ display:block; width:auto; height:auto; max-width:100%; }
