:root {
  --blue:         #336694;
  --blue-dark:    #2a527a;
  --blue-light:   #cfdff1;
  --blue-muted:   #5e8fab;
  --blue-pale:    #7aa5c4;
  --beige:        #F1E9CF;
  --beige-light:  #FAF7EC;
  --brown:        #C6A57E;
  --gray:         #666;
  --gray-light:   #ccc;
}

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

.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;
  top: -100%;
  left: 0;
  padding: 6px 12px;
  background: var(--blue);
  color: #fff;
  font-weight: bold;
  z-index: 9999;
}
.skip-link:focus { top: 0; }

body {
  margin: 5px;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 62.5%;
  line-height: 1.4;
  background: #fff;
  color: #000;
}

a { color: var(--blue); text-decoration: none; }
a:hover, a:active { text-decoration: underline; }

h1 {
  font-weight: normal;
  color: var(--blue);
  font-size: 3em;
  margin: 0;
  padding: 0;
}

h2 {
  font-weight: normal;
  color: var(--blue);
  border-bottom: 3px solid var(--blue);
  font-size: 1.6em;
  margin: 0 -5px;
  padding: 5px 10px;
  background: var(--beige);
}

h3 {
  font-size: 1.4em;
  font-weight: normal;
  color: var(--blue);
  margin: 10px 0 0;
}

h4 {
  font-size: 1.4em;
  font-weight: normal;
  color: var(--blue);
  margin: 10px 0 0;
}

h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover { text-decoration: none; }

ul { margin: 10px 20px; padding: 0; }
li { margin: 5px 10px; padding: 0; }

table { border-collapse: collapse; }
th, td { font-size: inherit; }

input, button, textarea, select {
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 0.85em;
}

input[type=button], input[type=submit], input[type=reset], button, .button {
  color: var(--beige);
  background: var(--blue);
  font-weight: bold;
}

/* ---- Page layout --------------------------------------------------------- */

#page {
  margin: 0 auto;
  max-width: 750px;
  font-size: 1.3em;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 10px;
}

#header .logo {
  margin: 0 10px -5px 0;
}

#header .logo h1 {
  margin: 0;
  letter-spacing: -1px;
}

#header .logo h1 a {
  text-decoration: none;
  color: inherit;
}

#header .logo .by-line {
  position: relative;
  top: -10px;
  left: 56px;
  color: var(--blue);
  letter-spacing: 1px;
  font-size: 1em;
}

#header .navigation {
  padding: 0 10px 0 0;
  color: var(--blue);
  text-align: right;
  white-space: nowrap;
  font-size: 1.1em;
}

.navigation a + a::before {
  content: " | ";
  color: var(--blue);
}

#content {
  clear: both;
  margin: 10px;
}

.left-column {
  float: left;
  width: calc(100% - 170px);
}

.right-column {
  float: right;
  width: 160px;
  margin-top: 10px;
}

.welcome-text {
  clear: both;
  margin-top: 10px;
}

#footer {
  border-top: 3px solid var(--blue);
  margin: 5px 10px 10px;
  padding: 5px 10px;
  background: var(--beige);
  font-size: 1.1em;
  clear: both;
}

#footer .navigation { float: left; }

.clear { clear: both; }

/* ---- Search form --------------------------------------------------------- */

.search-form {
  margin: 5px -5px;
  padding: 10px;
  background: var(--blue-light);
  line-height: 2;
  border-top: 3px solid var(--blue);
  font-size: 1.15em;
}

.search-form select.type  { min-width: 70px; }
.search-form select.location { min-width: 200px; }

.search-form .events label {
  margin-right: 10px;
  white-space: nowrap;
}

.button {
  padding: 3px 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
}

.button:hover { background: var(--blue-dark); }


/* ---- Results ------------------------------------------------------------- */

.results {
  margin: 5px -5px;
}

.results .header { margin: 5px; }

.results h4 {
  margin: 0 0 2px;
  font-size: 1.6em;
}

.results .coordinates {
  font-size: 0.95em;
  color: var(--gray);
}

.calendar-week {
  width: 100%;
  table-layout: fixed;
  margin: 8px 0 0 0;
  border-collapse: collapse;
  font-size: 0.9em;
}

.calendar-week th,
.calendar-week td {
  padding: 3px 6px;
  vertical-align: top;
}

.calendar-week .type-label {
  text-align: left;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.9em;
  padding: 3px 6px;
}

.calendar-week th.day-col {
  text-align: center;
  background: var(--blue);
  color: #fff;
  font-weight: bold;
}

.calendar-week td.day-cell {
  text-align: center;
}

.calendar-week .meas {
  color: var(--gray);
  font-size: 0.85em;
}

.tide-slot {
  min-height: 3em;
  white-space: nowrap;
}

.calendar-week tr.odd  td { background: var(--beige); border-left: 1px solid var(--gray-light); border-right: 1px solid var(--gray-light); }
.calendar-week tr.even td { background: #fff; border-left: 1px solid var(--gray-light); border-right: 1px solid var(--gray-light); }

.calendar-week th.day-placeholder { color: var(--blue-pale); }

.calendar-week th.day-past { background: var(--blue-muted); }
.calendar-week td.day-past { color: var(--gray); }

.results .footer {
  border-top: 5px solid var(--blue);
  padding: 5px;
  font-size: 0.95em;
}

/* ---- Skeleton loader ----------------------------------------------------- */

@keyframes skeleton-shimmer {
  from { background-position: 200% center; }
  to   { background-position: -200% center; }
}

.skeleton-bar {
  background: linear-gradient(90deg, #e0e0e0 25%, #efefef 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s linear infinite;
  border-radius: 2px;
}

.skeleton-title    { height: 22px; width: 55%; margin: 10px 0 6px; }
.skeleton-subtitle { height: 14px; width: 28%; margin-bottom: 6px; }

.calendar-week th.skeleton-day-header { height: 36px; }
.calendar-week td.skeleton-data-cell  { height: 72px; }
.week-chart-wrap.skeleton-bar         { height: 100px; }

/* ---- Tide chart ---------------------------------------------------------- */

.week-chart-wrap {
  margin: 0 -4px 14px -32px;
}

/* ---- Map dialog ---------------------------------------------------------- */

#map-dialog {
  border: 1px solid var(--brown);
  padding: 10px;
  background: var(--beige-light);
  max-width: 540px;
  width: 100%;
  font-size: 1.3em;
  position: relative;
}

#map-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--blue);
  font-size: 1.6em;
  font-weight: bold;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

#map-close:hover { color: var(--blue-dark); }

#map-dialog h2 {
  margin: 0 0 8px;
  font-size: 1em;
  color: var(--blue);
}

#map-container {
  width: 100%;
  height: 450px;
}

#map-hover-label {
  margin: 6px 0;
  font-size: 0.85em;
  color: var(--gray);
}

#map-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

/* ---- Print --------------------------------------------------------------- */

@media print {
  #header .navigation,
  .search-form,
  .right-column,
  .welcome-text,
  #footer,
  #map-dialog,
  #chart-container { display: none !important; }

  #header .logo h1 { font-size: 1.5em; }
  .left-column { float: none; width: 100%; }
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 780px) {
  #page { max-width: 100%; }

  .left-column,
  .right-column {
    float: none;
    width: 100%;
  }

  .right-column { margin-top: 0; }

  #header .navigation {
    padding: 5px 0;
    text-align: left;
  }

  #map-container { width: 100%; }
}

@media (max-width: 600px) {
  .search-form .locations,
  .search-form .dates {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }

  .week-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .week-scroll .calendar-week {
    min-width: 500px;
  }
  .week-scroll .week-chart-wrap {
    /* 532px + 4px for the negative margin. */
    min-width: 536px;
  }
}
