/* Cannabis Price Index - base styles
   Deliberately plain, grayscale, no house-style branding. */

:root {
  --bg: #121212;
  --surface: #1c1c1c;
  --surface-2: #262626;
  --text: #e9e9e9;
  --muted: #aeaeae;
  --border: #3a3a3a;
  --focus: #f2f2f2;
  --dot-legal: #eaeaea;
  --dot-illicit: #8f8f8f;
  --dot-user: #cfcfcf;
  --danger: #d8d8d8;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f3f3;
    --surface: #ffffff;
    --surface-2: #ececec;
    --text: #1a1a1a;
    --muted: #545454;
    --border: #cfcfcf;
    --focus: #000000;
    --dot-legal: #1a1a1a;
    --dot-illicit: #7a7a7a;
    --dot-user: #4a4a4a;
    --danger: #1a1a1a;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1c1c1c;
  --surface-2: #262626;
  --text: #e9e9e9;
  --muted: #aeaeae;
  --border: #3a3a3a;
  --focus: #f2f2f2;
  --dot-legal: #eaeaea;
  --dot-illicit: #8f8f8f;
  --dot-user: #cfcfcf;
}

:root[data-theme="light"] {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --surface-2: #ececec;
  --text: #1a1a1a;
  --muted: #545454;
  --border: #cfcfcf;
  --focus: #000000;
  --dot-legal: #1a1a1a;
  --dot-illicit: #7a7a7a;
  --dot-user: #4a4a4a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

header.site-header {
  padding: 20px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}

p.intro {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 4px;
}

p.intro.small {
  font-size: 0.82rem;
  margin-top: 8px;
}

section {
  margin: 28px 0;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}

/* Globe */

#globe-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#globe-canvas {
  width: 100%;
  max-width: 360px;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: none;
  cursor: grab;
  display: block;
}

#globe-canvas:active {
  cursor: grabbing;
}

.globe-hint {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  margin-top: 6px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.swatch.legal { background: var(--dot-legal); }
.swatch.illicit { background: var(--dot-illicit); }
.swatch.user {
  background: transparent;
  border: 2px solid var(--dot-user);
}

/* Trust-tier swatches (section 3): sourced-verified is a plain filled dot,
   consensus-verified adds a contrasting ring around the same fill, and
   single-submission-unverified is a hollow ring only. */
.swatch.tier-sourced { background: var(--dot-legal); }
.swatch.tier-consensus {
  background: var(--dot-legal);
  border: 2px solid var(--text);
  box-shadow: 0 0 0 1px var(--bg);
}
.swatch.tier-single {
  background: transparent;
  border: 2px solid var(--dot-user);
}

/* Local view panel */

#local-view {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px;
  display: none;
}

#local-view.open { display: block; }

#local-view .local-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.close-local {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.entry-card {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}

.entry-card:first-of-type { border-top: none; }

.entry-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.entry-price {
  font-weight: 600;
  font-size: 1.05rem;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.tag.verified,
.tag.sourced { color: var(--text); border-color: var(--text); }
.tag.unverified { color: var(--muted); }
.tag.consensus {
  color: var(--text);
  border-color: var(--text);
  border-width: 2px;
}

.entry-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}

.entry-meta a { color: var(--muted); }
.entry-note {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 4px;
  font-style: italic;
}

/* Filters + table */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

select, input[type="text"], input[type="number"], input[type="file"], textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  min-height: 44px;
  width: 100%;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

select:focus, input:focus, button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 560px;
}

thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }

td.src a { color: var(--muted); }

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

/* Form */

form#submit-form {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label, .field .field-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.toggle-row {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  flex: 1;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}

.toggle-btn[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.range-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.range-row input { flex: 1; min-width: 0; }

.range-sep { color: var(--muted); }

button.primary {
  min-height: 44px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 600;
}

.form-note {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 10px;
}

.view-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.view-toggle button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

footer {
  color: var(--muted);
  font-size: 0.76rem;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 36px;
}

/* Identity section */

#identity-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px;
}

.identity-badge {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.identity-badge strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}

.identity-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.identity-actions button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
}

.import-key-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.import-key-panel label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px 0 6px;
}

.import-key-panel button {
  min-height: 44px;
  margin-top: 10px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 8px;
}

.identity-warning {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 12px 0 0;
}

/* Tip section reuses .field/.form-note/button.primary from the submit form */

#tip-section form {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px;
}

@media (min-width: 560px) {
  .wrap { padding: 32px 24px 80px; }
  h1 { font-size: 1.6rem; }
}
