/* ============================================================
   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;

  /* Spacing scale */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;
  --space-2xl: 4rem;

  /* Surface — subtle background for cards and callout boxes */
  --surface: #f7f5f2;
}

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


/* ── 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;
  animation: page-in 0.2s ease-out;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}

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);
  position: relative;
  padding-bottom: 4px;

  /* Underline custom properties */
  --uln-offset:       2px;
  --uln-h:            2px;
  --uln-opacity:      1;
  --uln-taper:        4px;
  --uln-pan-duration: 17s;
  --uln-cycle:        8s;
}

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

/* Rainbow underline — exact match to erickrueger.com */
.site-name::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + var(--uln-offset));
  height: var(--uln-h);
  opacity: var(--uln-opacity);
  border-radius: 9999px;
  pointer-events: none;

  background-image: linear-gradient(90deg,
    hsl(0 100% 50%),
    hsl(30 100% 50%),
    hsl(60 100% 50%),
    hsl(90 100% 50%),
    hsl(120 100% 47%),
    hsl(150 100% 50%),
    hsl(180 100% 50%),
    hsl(210 100% 55%),
    hsl(240 100% 60%),
    hsl(270 100% 55%),
    hsl(300 100% 50%),
    hsl(330 100% 50%)
  );
  background-size: 300% 100%;
  background-position: 0% 0%;

  clip-path: polygon(
    0 50%,
    var(--uln-taper) 0,
    calc(100% - var(--uln-taper)) 0,
    100% 50%,
    calc(100% - var(--uln-taper)) 100%,
    var(--uln-taper) 100%
  );

  animation: uln-pan var(--uln-pan-duration) linear infinite;
  filter: saturate(1);
  will-change: background-position;
  transform: translateZ(0);
  backface-visibility: hidden;
}

@keyframes uln-pan { to { background-position: -300% 0%; } }

/* Reduced motion: stop pan */
@media (prefers-reduced-motion: reduce) {
  .site-name::after {
    animation: none;
  }
}

/* OKLCH override for modern browsers */
@supports (color: oklch(0.7 0.2 0)) {
  .site-name::after {
    background-image: linear-gradient(90deg,
      oklch(0.72 0.22  20),
      oklch(0.72 0.22  50),
      oklch(0.72 0.22  80),
      oklch(0.72 0.22 110),
      oklch(0.72 0.22 140),
      oklch(0.72 0.22 170),
      oklch(0.72 0.22 200),
      oklch(0.72 0.22 230),
      oklch(0.72 0.22 260),
      oklch(0.72 0.22 290),
      oklch(0.72 0.22 320)
    );
  }
}

.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;
}

/* Skeleton shimmer — applied by JS while stats are loading */
@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

.stat-skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    color-mix(in srgb, var(--border) 40%, var(--bg)) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 3px;
  color: transparent !important;
  min-width: 2.5rem;
  user-select: none;
}


/* ── 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 — dot style */
.map-dot-marker {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Do NOT set position: relative here — Leaflet's CSS sets
     position: absolute on .leaflet-marker-icon. Overriding it with
     position: relative breaks marker placement on the map. */
  background: none;
  border: none;
}

.dot-core {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--link);
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  position: relative; /* establishes z-index stacking without breaking flex */
  z-index: 1;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.map-dot-marker.marker-active .dot-core {
  transform: scale(1.25);
}

.dot-ripple {
  /* Absolutely positioned relative to the marker element (position:absolute
     from Leaflet). Centered explicitly since abs-positioned elements are
     removed from flex layout. */
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  border: 2px solid var(--link);
  opacity: 0;
  pointer-events: none;
}

.map-dot-marker.marker-active .dot-ripple {
  animation: dot-ripple-expand 1.5s ease-out infinite;
}

@keyframes dot-ripple-expand {
  0%   { transform: scale(1);   opacity: 0.35; }
  100% { transform: scale(5.5); opacity: 0;    }
}

/* 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"],
input[type="password"],
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,
input[type="password"]: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;
}

.hint-warn {
  font-size: 0.78rem;
  color: #b06000;
  margin-top: 0.3rem;
}

@media (prefers-color-scheme: dark) {
  .hint-warn { color: #e0a050; }
}

/* 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; }

.btn-submit:focus-visible,
#scan-btn:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.btn-nav:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.btn-text:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 2px;
}

/* 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);
}


/* ── How it works ─────────────────────────────────────────── */

.steps {
  list-style: none;
  counter-reset: step-counter;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.steps li {
  counter-increment: step-counter;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.steps li::before {
  content: counter(step-counter);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--link);
  color: #fff;
  font-size: 0.72rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  .steps li::before { color: #01242e; }
}

.steps li strong {
  display: block;
  color: var(--heading);
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
}

.steps li span {
  display: block;
  font-size: 0.8rem;
  color: var(--subtle);
  line-height: 1.5;
}


/* ── Share buttons ────────────────────────────────────────── */

.btn-share {
  display: inline-block;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.3rem 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-share:hover { border-color: var(--link); color: var(--link); }

.btn-share:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}


/* ── 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; }
}
