/* ============================================================
   Small Black Coffee Index — Stylesheet
   Matches erickrueger.com design system
   ============================================================ */


/* ── Variables (light mode) ───────────────────────────────── */

:root {
  --width:   800px;
  --font:    Verdana, sans-serif;
  --bg:      #fff;
  --heading: #222;
  --text:    #444;
  --link:    #3273dc;
  --visited: #8b6fcb;
  --subtle:  #888;
  --border:  #ddd;
  --code-bg: #f2f2f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #01242e;
    --heading: #eee;
    --text:    #ddd;
    --link:    #8cc2dd;
    --visited: #c9b8e8;
    --subtle:  #7aabb8;
    --border:  #1e4a57;
    --code-bg: #000;
  }
}


/* ── Reset ────────────────────────────────────────────────── */

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


/* ── Base ─────────────────────────────────────────────────── */

body {
  font-family: var(--font);
  font-size: 1em;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  padding: 20px;
}

a {
  color: var(--link);
}

a:visited {
  color: var(--visited);
}

h1, h2, h3 {
  color: var(--heading);
  line-height: 1.3;
}


/* ── Layout ───────────────────────────────────────────────── */

.container {
  max-width: var(--width);
  margin: 0 auto;
}


/* ── Header ───────────────────────────────────────────────── */

header {
  max-width: var(--width);
  margin: 0 auto 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.site-name {
  font-size: 1.4rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--heading);

  /* Rainbow underline animation — signature erickrueger.com element */
  background-image: linear-gradient(
    90deg,
    oklch(0.68 0.22 0),
    oklch(0.68 0.22 60),
    oklch(0.72 0.20 120),
    oklch(0.70 0.20 180),
    oklch(0.65 0.22 240),
    oklch(0.68 0.22 300),
    oklch(0.68 0.22 360)
  );
  background-size: 200% 2px;
  background-repeat: no-repeat;
  background-position: 0% 100%;
  padding-bottom: 3px;
  animation: rainbow-pan 17s linear infinite;
}

.site-name:visited {
  color: var(--heading);
}

.site-name:hover {
  animation-play-state: paused;
}

@keyframes rainbow-pan {
  from { background-position: 0%   100%; }
  to   { background-position: 200% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .site-name {
    animation: none;
    background-image: none;
  }
}

.header-nav {
  font-size: 0.85rem;
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.header-nav a {
  text-decoration: none;
  color: var(--subtle);
}

.header-nav a:hover {
  color: var(--link);
  text-decoration: underline;
}

.btn-nav {
  background: var(--link);
  color: #fff !important;
  padding: 0.3rem 0.85rem;
  border-radius: 3px;
  text-decoration: none !important;
  font-weight: bold;
  transition: opacity 0.15s;
}

.btn-nav:hover {
  opacity: 0.85;
  text-decoration: none !important;
}

@media (prefers-color-scheme: dark) {
  .btn-nav { color: #01242e !important; }
}


/* ── Stats bar ────────────────────────────────────────────── */

.stats-bar {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--subtle);
  flex-wrap: wrap;
}

.stat strong {
  display: block;
  font-size: 1.4rem;
  color: var(--heading);
  line-height: 1.2;
}


/* ── Sections ─────────────────────────────────────────────── */

section {
  margin-bottom: 2.5rem;
}

h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtle);
  font-weight: normal;
  margin-bottom: 0.6rem;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--subtle);
  margin-bottom: 0.8rem;
}


/* ── Map ──────────────────────────────────────────────────── */

#map {
  height: 480px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Custom map marker */
.map-pin {
  color: #5c3317;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

@media (prefers-color-scheme: dark) {
  .map-pin { color: #c07a45; }
}

/* Leaflet popup styling */
.leaflet-popup-content {
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.5;
}


/* ── Chart ────────────────────────────────────────────────── */

.chart-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.2rem;
}

#trend-chart {
  max-height: 300px;
}


/* ── Submit form ──────────────────────────────────────────── */

.submit-intro {
  margin-bottom: 1.8rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
}

.field {
  margin-bottom: 1.4rem;
}

.field-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.field-grow  { flex: 1; }
.field-shrink { flex: 0 0 130px; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--heading);
  margin-bottom: 0.35rem;
}

.optional {
  font-weight: normal;
  color: var(--subtle);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--link) 20%, transparent);
}

input[type="file"] {
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--subtle);
  width: 100%;
}

.hint {
  font-size: 0.78rem;
  color: var(--subtle);
  margin-top: 0.3rem;
}

/* Location autocomplete */
.location-wrap {
  position: relative;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 3px 3px;
  list-style: none;
  margin: 0;
  padding: 0;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.suggestions li {
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.4;
}

.suggestions li:last-child {
  border-bottom: none;
}

.suggestions li:hover,
.suggestions li.active {
  background: color-mix(in srgb, var(--link) 10%, transparent);
  color: var(--heading);
}

.suggestions li .suggestion-name {
  font-weight: bold;
  display: block;
}

.suggestions li .suggestion-addr {
  color: var(--subtle);
  font-size: 0.78rem;
}

/* Confirmed location display */
.location-confirmed {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: color-mix(in srgb, var(--link) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--link) 30%, transparent);
  border-radius: 3px;
  font-size: 0.85rem;
}

.location-confirmed-text {
  flex: 1;
  line-height: 1.4;
  color: var(--text);
}

.location-confirmed-coords {
  font-size: 0.75rem;
  color: var(--subtle);
  margin-top: 0.15rem;
  font-family: monospace;
}

.btn-text {
  background: none;
  border: none;
  color: var(--link);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0;
  text-decoration: underline;
  white-space: nowrap;
}

/* Submit button */
.btn-submit {
  display: block;
  width: 100%;
  padding: 0.75rem 1.4rem;
  background: var(--link);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.15s;
}

/* In dark mode the link color is a light blue — use dark text for contrast */
@media (prefers-color-scheme: dark) {
  .btn-submit { color: #01242e; }
}

.btn-submit:hover    { opacity: 0.85; }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* Status messages */
#status {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 3px;
  font-size: 0.88rem;
  line-height: 1.5;
}

#status.success {
  display: block;
  background: color-mix(in srgb, #2a7a2a 10%, transparent);
  border: 1px solid color-mix(in srgb, #2a7a2a 30%, transparent);
  color: var(--text);
}

#status.error {
  display: block;
  background: color-mix(in srgb, #c0392b 10%, transparent);
  border: 1px solid color-mix(in srgb, #c0392b 30%, transparent);
  color: var(--text);
}


/* ── Footer ───────────────────────────────────────────────── */

footer {
  max-width: var(--width);
  margin: 3rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--subtle);
}

footer a { color: var(--subtle); }


/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 600px) {
  body { padding: 12px; }

  header {
    flex-direction: column;
    gap: 0.6rem;
  }

  .stats-bar { gap: 1.2rem; }

  .field-row {
    flex-direction: column;
  }
  .field-shrink { flex: 1; }

  #map { height: 320px; }
}
