/* Base */
body, table { font: 9pt 'Trebuchet MS', Arial, Helvetica, sans-serif; }
img  { border: none; }

/* Outer page */
html { height: 100%; }

body.home {
  height: 100%;
  margin: 0;
  padding: 8px;
  box-sizing: border-box;
  background: rgb(187,187,153) url('/img/BackFlowB.jpg') top left repeat-x;
}

/* Central container */
#site-wrapper {
  max-width: 1100px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: transparent;
}

#site-header { margin-bottom: 4px; }
#layout-body { margin-bottom: 4px; }

#site-header,
#site-footer {
  border: 2px solid rgb(255,255,255);
  border-radius: 8px;
  overflow: hidden;
}
#layout-body #sidebar, #content {
  border: 2px solid rgb(255,255,255);
  border-radius: 8px;
  overflow: hidden;
}

/* Header card */
#site-header {
  flex-shrink: 0;
  height: 66px;
  background: #E6E6E6 url('/img/HeaderFlowB.jpg') top left repeat-x;
  padding: 0 8px 0 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#brand-link { flex: 1; display: block; height: 52px; padding-left: 6px; }
#brand-svg  { height: 52px; width: auto; }

#header-search {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}
#search-name, #search-coords { display: flex; align-items: center; gap: 4px; }

input.search {
  font: 9pt 'Trebuchet MS',Arial,Helvetica,Sans-serif;
  border: 1px solid #FFFFFF;
  background: #F8F8F8;
  height: 20px;
  margin: 0px 0px 0px 4px;
}
textarea.search {
  font: 9pt 'Trebuchet MS', Arial, Helvetica, sans-serif;
  border: 1px solid #ccc;
  background: #f8f8f8;
  padding: 2px 4px;
}
input.loupe { border: 0; cursor: pointer; vertical-align: middle; margin-left: 4px; }

#search-name input.search,
#search-coords input.search { height: 20px; box-sizing: border-box; margin: 0 0 0 4px; }
#search-name input.search   { width: 200px; }
#search-coords input.search { width: 100px; }
#search-q, #search-lat, #search-lon { border: 1px solid #fff; }

/* Hemisphere toggles */
.latCbx input, .lonCbx input { display: none; }
.latCbx input + label {
  padding: 0 0 0 22px; margin-left: 2px; height: 20px;
  display: inline-block; line-height: 20px; cursor: pointer;
  background: url('/img/LatLonN.png') no-repeat left center;
}
.latCbx input:checked + label { background: url('/img/LatLonS.png') no-repeat left center; }
.lonCbx input + label {
  padding: 0 0 0 22px; margin-left: 2px; height: 20px;
  display: inline-block; line-height: 20px; cursor: pointer;
  background: url('/img/LatLonE.png') no-repeat left center;
}
.lonCbx input:checked + label { background: url('/img/LatLonW.png') no-repeat left center; }

/* Body layout */
#layout-body {
  display: flex;
  flex: 1;
  gap: 4px;
  min-height: 0;
}

/* Sidebar */
#sidebar {
  width: 192px;
  flex-shrink: 0;
  background: rgb(230,230,230);
  border-right: 1px solid rgb(204,204,204);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

div.foldhead {
  flex-shrink: 0;
  background: rgb(246,246,246) url('/img/SectionFlowB.jpg') top left repeat-x;
  padding: 5px 0 6px 4px;
  font-weight: bold;
  border-top: 1px solid rgb(255,255,255);
}
div.foldhead:first-child { border-top: none; }

div.foldercontainer {
  flex: 1;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 2px 0 2px 8px;
  background: rgb(230,230,230);
}

div.folderlist      { padding: 1px 0; }
div.folder-children { margin-left: 12px; }
div.menucontainer {
  flex-shrink: 0;
  padding: 1px 0 1px 10px;
  background: rgb(230,230,230);
  border-top: 1px solid rgb(204,204,204);
}

/* Links */
a:link, a:visited, a:hover, a:active { text-decoration: none; color: rgb(136,51,17); }
a:hover { text-decoration: underline; }

a.nav         { display: block; font-size: 8pt; padding: 2px 0 1px 20px; }
a.folder      { background: url('/img/icn_folder.png')    no-repeat left center; font-weight: bold; color: rgb(180,80,10); }
a.section     { padding-left: 28px; background: url('/img/icn_hmp.png')      no-repeat left center; }
a.sectionlast { padding-left: 28px; background: url('/img/icn_hmplast.png')  no-repeat left center; }
a.link        { padding: 3px 0 3px 20px; }
a.info        { background: url('/img/icn_info.png')     no-repeat left center; }
a.list        { background: url('/img/icn_list.png')     no-repeat left center; }
a.map         { background: url('/img/icn_map.png')      no-repeat left center; }
a.web         { background: url('/img/icn_web14.png')    no-repeat left center; }
a.noweb       { background: url('/img/icn_noweb14.png')  no-repeat left center; }
a.ge          { background: url('/img/icn_ge.png')       no-repeat left center; }
a.lily        { background: url('/img/AncLocLily16.png')   no-repeat left center; }
a.lilylight   { background: url('/img/AncLocLily16t.png')  no-repeat left center; }
a.coords      { color: rgb(153,68,34); font-size: 8pt; }
a.coords:hover { text-decoration: underline; }
a.extlink img  { margin: 0 1px; }

/* Button */
a.btn {
  font-size: 9pt;
  border: 1px solid rgb(153,153,153);
  background: rgb(246,246,246) url('/img/bflow.jpg') center center repeat-x;
  border-radius: 5px;
  color: rgb(0,0,0);
  padding: 2px 6px 3px 6px;
  text-align: center;
  display: inline-block;
  cursor: pointer;
  text-decoration: none;
}
a.btn:hover { background-color: rgb(220,220,200); text-decoration: none; }

/* Content area */
#content {
  flex: 1;
  min-width: 0;
  background: rgb(238,238,238);
  overflow-y: auto;
}
#view-container { min-height: 100%; padding-bottom: 0; }
#view-container > * { margin-bottom: 0; }

/* Footer card */
#site-footer {
  flex-shrink: 0;
  height: 32px;
  line-height: 32px;
  text-align: center;
  padding: 0 3px;
  background: #E6E6E6 url('/img/HeaderFlowB.jpg') top left repeat-x;
  color: rgb(136,51,17);
  font-size: 9pt;
}

/* Placemark table */
table.places { border-collapse: collapse; empty-cells: show; width: 100%; }

tr.placesfolder { background: rgb(246,246,246) url('/img/SectionFlowB.jpg') top left repeat-x; }
td.placesfolder { font-size: 10pt; font-weight: bold; text-align: center; padding: 5px; }

td.placessection {
  border: 1px solid rgb(221,221,221);
  padding: 1px 5px;
  white-space: nowrap;
  text-align: center;
  vertical-align: top;
  background: rgb(246,246,246);
  font-weight: bold;
}

td.pmgap { background: rgb(240,240,240); height: 4px; font-size: 0; padding: 0; }

tr.places td       { background: rgb(238,238,238); cursor: default; }
tr.places:hover td { background: rgb(204,238,153); }
tr.selected td     { background: rgb(255,255,204); }

td.places      { border: 1px solid rgb(221,221,221); padding: 1px 5px; white-space: nowrap; }
td.placesfirst { border: 1px solid rgb(230,230,230); padding: 1px 5px; white-space: nowrap; font-weight: bold; }
td.placesimg   { border: 1px solid rgb(230,230,230); padding: 1px 2px 0 2px; vertical-align: middle; white-space: nowrap; }
td.modern      { font-style: italic; }
td.intercaption { background: rgb(246,246,246); color: rgb(119,119,119); font-weight: bold; text-align: center; }

.acc-uncertain { color: rgb(153,68,34); font-size: 8pt; font-weight: bold; cursor: help; }
.pmnew         { color: rgb(51,153,0);  cursor: help; }
.pmupd         { color: rgb(51,153,255); cursor: help; }

/* Placemark detail */
.detail-header {
  background: rgb(246,246,246) url('/img/SectionFlowB.jpg') top left repeat-x;
  padding: 6px 8px;
  border-bottom: 1px solid rgb(221,221,221);
}
.detail-header h1               { font-size: 11pt; font-weight: bold; margin: 0 0 2px; color: rgb(136,51,17); }
.detail-header .detail-altnames { font-style: italic; color: rgb(102,68,34); }
.detail-header .detail-region   { color: rgb(119,119,119); font-size: 8pt; }

.detail-coords {
  background: rgb(242,242,242);
  padding: 4px 8px;
  font-size: 8pt;
  border-bottom: 1px solid rgb(221,221,221);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.coord-val  { font-weight: bold; color: rgb(136,51,17); }
.acc-badge  { color: rgb(153,68,34); font-size: 8pt; border: 1px solid rgb(153,68,34); border-radius: 3px; padding: 1px 4px; }
.coord-ext a   { margin-left: 2px; }
.coord-ext img { width: 14px; height: 14px; vertical-align: middle; }

#detail-map { width: 100%; height: 300px; border-bottom: 1px solid rgb(221,221,221); }

.detail-section    { padding: 6px 8px; border-bottom: 1px solid rgb(238,238,238); }
.detail-section h3 { font-size: 8pt; font-weight: bold; color: rgb(119,119,119); margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-text       { font-size: 9pt; line-height: 1.5; }

.phases-table        { width: 100%; border-collapse: collapse; font-size: 9pt; }
.phases-table td     { padding: 2px 5px; border: 1px solid rgb(238,238,238); vertical-align: top; }
td.pmphase           { background: rgb(242,242,242); font-weight: bold; }
td.pmval             { background: rgb(250,250,250); }
td.pmkey             { text-align: right; vertical-align: top; background: rgb(246,246,246); color: rgb(119,119,119); }
.phase-date          { color: rgb(102,68,34); }

.ext-ref-list    { list-style: none; padding: 0; margin: 0; }
.ext-ref-list li { padding: 2px 0; font-size: 9pt; }

.nearby-table             { width: 100%; border-collapse: collapse; font-size: 9pt; }
.nearby-table td          { padding: 2px 5px; border: 1px solid rgb(238,238,238); }
.nearby-table tr:hover td { background: rgb(204,238,153); }

/* Sources */
td.sourcecaption {
  border: none;
  font-size: 10pt;
  font-weight: bold;
  text-align: left;
  padding: 5px 5px 5px 24px;
  background: url('/img/icn_web.png') no-repeat 4px center;
}
td.sourcesection {
  border: 1px solid rgb(221,221,221);
  padding: 1px 5px;
  white-space: nowrap;
  text-align: left;
  vertical-align: top;
  background: rgb(246,246,246);
  font-weight: bold;
}
.selectedsource td.sourcecaption { background-color: rgb(255,255,204); }
.selectedsource td.sourcesection { background-color: rgb(255,255,204); }

/* Utilities */
.loading { padding: 20px; color: rgb(119,119,119); text-align: center; }
.error   { padding: 20px; color: #c00; }
.grey    { color: rgb(153,153,153); }
.righted { text-align: right; }

/* Leaflet — eliminate sub-pixel tile seam artefact */
.leaflet-container img.leaflet-tile { backface-visibility: hidden; }

/* About page */
.about-section-label {
  font-weight: bold;
  font-size: 9pt;
  padding: 4px 0 2px;
  color: rgb(119,119,119);
}

/* Hamburger toggle (desktop: hidden) */
#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  color: rgb(136,51,17);
}

/* Responsive — 768px breakpoint */
@media screen and (max-width: 768px) {

  body.home {
    padding: 0;
    height: auto;
    min-height: 100%;
  }

  #site-wrapper {
    height: auto;
    min-height: 100%;
    gap: 2px;
  }

  #site-header,
  #site-footer {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  #layout-body #sidebar,
  #content {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  #site-header {
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 4px;
    padding: 4px;
  }

  #sidebar-toggle { display: block; }

  #header-search {
    order: 3;
    width: 100%;
    align-items: stretch;
  }

  #search-coords { display: none; }

  #search-name { width: 100%; justify-content: stretch; }
  #search-name input.search { flex: 1; width: auto; }

  #layout-body { gap: 0; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 3px 0 10px rgba(0,0,0,0.35);
    border: none;
    border-radius: 0;
    overflow-y: auto;
  }

  #sidebar.open { transform: translateX(0); }

  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
  }

  #sidebar-backdrop.open { display: block; }

  #content {
    width: 100%;
    overflow-x: hidden;
  }

  #view-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #site-footer { border-top: none; }
}
