/* ===================================================================
   EnviroViewer — shared styles
   Plain CSS, no frameworks. Mobile-first, clean and minimal.
   =================================================================== */

/* --- Reset & base ------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #1a1a2e;
  background: #fafbfc;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* --- Header & navigation ------------------------------------------------ */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.75rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.site-title em {
  font-style: italic;
  font-weight: 700;
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.tab-bar a {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
}

.tab-bar a:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.tab-bar a.active {
  color: #0f172a;
  background: #f1f5f9;
  font-weight: 600;
}

/* --- Main content ------------------------------------------------------- */
.page-body {
  flex: 1;
  width: 100%;
}

/* Constrained content wrapper (landing page, etc.) */
.content-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

/* --- Landing page: hero ------------------------------------------------- */
.hero {
  max-width: 640px;
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: #0f172a;
}

.hero p {
  font-size: 1.125rem;
  color: #475569;
  line-height: 1.7;
}

/* --- Tool card grid ----------------------------------------------------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.tool-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.75rem;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}

.tool-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.tool-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #0f172a;
}

.tool-card p {
  font-size: 0.9375rem;
  color: #64748b;
  flex: 1;
}

.tool-card .card-arrow {
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #3b82f6;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* --- Iframe wrapper (tool pages) ---------------------------------------- */
.iframe-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.iframe-wrap iframe {
  flex: 1;
  width: 100%;
  min-height: 800px;
  border: none;
  display: block;
}

/* --- Footer ------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid #e5e7eb;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: #94a3b8;
}

.site-footer a {
  color: #64748b;
  text-decoration: underline;
  text-decoration-color: #cbd5e1;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.site-footer a:hover {
  color: #0f172a;
}

/* --- Tide Viewer: layout ------------------------------------------------ */
.tv-layout {
  position: relative;
  overflow: hidden;
  /* Fill viewport below the sticky header */
  height: calc(100vh - 3.75rem);
}

.tv-layout #map {
  width: 100%;
  height: 100%;
  min-height: 500px;  /* fallback if calc/JS sizing fails */
  z-index: 1;
}

/* Station-count badge */
.tv-status {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 0.3rem 1rem;
  font-size: 0.75rem;
  color: #64748b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Cluster icon */
.station-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3b82f6;
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* --- Tide Viewer: bottom panel ------------------------------------------ */
.tv-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
  border-radius: 0.75rem 0.75rem 0 0;
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  /* Hidden off-screen by default */
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0.3s;
}

.tv-panel.open {
  transform: translateY(0);
  visibility: visible;
}

.tv-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
  flex-shrink: 0;
}

.tv-panel-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.tv-station-id {
  font-size: 0.8rem;
  color: #94a3b8;
}

.tv-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 0.25rem;
}
.tv-close:hover { color: #0f172a; }

.tv-panel-body {
  padding: 0 1.25rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Controls row */
.tv-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.tv-controls label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

.tv-controls input[type="date"] {
  margin-top: 0.2rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-family: inherit;
  color: #0f172a;
}
.tv-controls input[type="date"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.tv-btn {
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: #3b82f6;
  color: #fff;
  transition: background 0.15s;
}
.tv-btn:hover { background: #2563eb; }

.tv-btn-alt {
  background: #f1f5f9;
  color: #0f172a;
}
.tv-btn-alt:hover { background: #e2e8f0; }

/* Chart container */
.tv-chart-wrap {
  position: relative;
  height: 220px;
}

.tv-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: #94a3b8;
  z-index: 2;
}

.tv-error {
  padding: 0.75rem;
  border-radius: 0.375rem;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
}

/* --- Utility ------------------------------------------------------------ */
.hidden {
  display: none !important;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .content-wrap {
    padding: 2rem 1rem;
  }

  .tool-card {
    padding: 1.25rem;
  }
}
