/* ============================================
   PLASTIQ — CSS
   Theme: Dark Beige bg, Dark Green borders
   ============================================ */

:root {
  --bg:           #2b2620;
  --bg-card:      #33302a;
  --bg-input:     #3a362f;
  --beige-light:  #d4c4a8;
  --beige-mid:    #b8a48a;
  --beige-dim:    #8a7a66;
  --green-dark:   #2d5a27;
  --green-mid:    #3d7a35;
  --green-bright: #5aad4e;
  --green-glow:   rgba(90, 173, 78, 0.18);
  --red-harm:     #c0392b;
  --amber:        #d4a017;
  --text-primary: #e8dcc8;
  --text-secondary:#b8a48a;
  --text-dim:     #7a6e5e;
  --border:       #2d5a27;
  --border-mid:   #3d7a35;
  --radius:       10px;
  --radius-sm:    6px;
  --font-main:    'Space Grotesk', sans-serif;
  --font-mono:    'Space Mono', monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── HEADER ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2.5rem;
  border-bottom: 1.5px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 0 6px var(--green-bright));
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--beige-light);
}

.tagline {
  font-size: 0.8rem;
  color: var(--green-bright);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* ── INPUT SECTION ── */
.input-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 70px);
  padding: 3rem 1.5rem;
}

.input-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 0 40px rgba(45, 90, 39, 0.12);
}

.input-heading {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--beige-light);
  line-height: 1.2;
  margin-bottom: 0.6rem;
}

.input-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* ── TABS ── */
.input-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 0.8rem;
}

.tab-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.55rem 1.1rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  border-color: var(--green-bright);
  color: var(--beige-light);
}

.tab-btn.active {
  background: var(--green-dark);
  border-color: var(--green-bright);
  color: var(--beige-light);
  font-weight: 600;
}

/* ── TAB PANELS ── */
.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* ── DROP ZONE ── */
.drop-zone {
  border: 2px dashed var(--border-mid);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-input);
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--green-bright);
  background: rgba(45, 90, 39, 0.15);
  box-shadow: 0 0 20px var(--green-glow);
}

.drop-icon { font-size: 2.5rem; margin-bottom: 0.8rem; }
.drop-text  { font-size: 1rem; color: var(--text-primary); margin-bottom: 0.25rem; }
.drop-sub   { font-size: 0.8rem; color: var(--text-dim); }

/* ── UPLOAD PREVIEW ── */
.preview-wrap {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-wrap img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
  background: var(--bg-input);
}

.clear-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(43, 38, 32, 0.85);
  border: 1.5px solid var(--border);
  color: var(--beige-mid);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.clear-btn:hover { border-color: var(--red-harm); color: #e74c3c; }

/* ── WEBCAM ── */
.webcam-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webcam-wrap video,
.webcam-wrap .webcam-captured,
.webcam-wrap img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.webcam-controls {
  display: flex;
  gap: 0.8rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ── BUTTONS ── */
.btn-primary {
  background: var(--green-dark);
  border: 1.5px solid var(--green-bright);
  color: var(--beige-light);
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--green-mid);
  box-shadow: 0 0 12px var(--green-glow);
}

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--green-bright); color: var(--beige-light); }

.btn-analyze {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  margin-top: 1.5rem;
  background: var(--green-dark);
  border: 1.5px solid var(--green-bright);
  border-radius: var(--radius);
  color: var(--beige-light);
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.9rem;
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 0.02em;
}

.btn-analyze:hover:not(:disabled) {
  background: var(--green-mid);
  box-shadow: 0 0 24px var(--green-glow);
  transform: translateY(-1px);
}

.btn-analyze:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── SPINNER ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--green-bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ── RESULTS SECTION ── */
.results-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.results-section.hidden { display: none; }

/* ── RESULT CARD ── */
.result-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 0 30px rgba(45, 90, 39, 0.08);
}

.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--green-bright);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* ── PLASTIC IDENTITY ── */
.plastic-identity {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.8rem;
}

.plastic-code-wrap {
  flex-shrink: 0;
}

.plastic-code {
  width: 72px; height: 72px;
  border: 2.5px solid var(--green-bright);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green-bright);
  background: rgba(90, 173, 78, 0.1);
  box-shadow: 0 0 16px var(--green-glow);
}

.plastic-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--beige-light);
  line-height: 1.1;
  margin-bottom: 0.3rem;
}

.plastic-fullname {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
}

.confidence-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.82rem;
}

.conf-label { color: var(--text-dim); }

.conf-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.conf-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green-dark), var(--green-bright));
  border-radius: 3px;
  transition: width 1s ease;
  width: 0%;
}

.conf-pct {
  font-family: var(--font-mono);
  color: var(--green-bright);
  font-size: 0.85rem;
  min-width: 40px;
}

/* ── DETAILS GRID ── */
.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.8rem;
}

.detail-item {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.detail-label {
  font-size: 0.73rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.detail-value {
  font-size: 0.95rem;
  color: var(--beige-light);
  font-weight: 600;
}

.detail-value.danger { color: #e74c3c; }
.detail-value.warn   { color: var(--amber); }
.detail-value.safe   { color: var(--green-bright); }

/* ── IMPACT CARD ── */
.impact-card { border-color: var(--green-dark); }

.impact-headline {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--beige-light);
  margin-bottom: 1.5rem;
  line-height: 1.35;
}

/* Timeline */
.timeline-section {
  margin-bottom: 1.8rem;
}

.timeline-label {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

.timeline-track {
  position: relative;
  height: 52px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 30px;
  overflow: hidden;
}

.timeline-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 30px;
  background: linear-gradient(90deg, var(--green-dark) 0%, var(--amber) 50%, #c0392b 100%);
  transition: width 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.timeline-markers {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.timeline-pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
}

.timeline-pin-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--beige-light);
  background: var(--bg-card);
  z-index: 2;
}

.timeline-pin-label {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--beige-light);
  white-space: nowrap;
  margin-top: 3px;
  background: rgba(43, 38, 32, 0.7);
  padding: 1px 4px;
  border-radius: 3px;
}

.timeline-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.tl-leg-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.tl-leg-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Harm grid */
.harm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.harm-item {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  text-align: center;
}

.harm-icon  { font-size: 1.6rem; margin-bottom: 0.3rem; }
.harm-stat  { font-size: 1.1rem; font-weight: 700; color: #e74c3c; font-family: var(--font-mono); }
.harm-desc  { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.2rem; }

/* Animal impact */
.animal-impact {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}

.animal-icon { font-size: 2.2rem; }
.animal-name { font-size: 1rem; font-weight: 700; color: var(--beige-light); }
.animal-desc { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* Emotional quote */
.emotional-quote {
  border-left: 3px solid var(--green-bright);
  padding: 0.8rem 1.2rem;
  background: rgba(90, 173, 78, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
  color: var(--beige-light);
  line-height: 1.6;
  font-style: italic;
}

/* ── ALTERNATIVES ── */
.alt-heading {
  font-size: 1.1rem;
  color: var(--beige-mid);
  margin-bottom: 1.2rem;
  font-weight: 500;
}

.alternatives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.alt-card {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.22s;
}

.alt-card:hover {
  border-color: var(--green-bright);
  box-shadow: 0 0 18px var(--green-glow);
  transform: translateY(-2px);
}

.alt-img-wrap {
  position: relative;
  height: 140px;
  overflow: hidden;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1.5px solid var(--border);
}

.alt-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s;
}

.alt-img-wrap img.loaded { opacity: 1; }

.alt-img-placeholder {
  font-size: 3rem;
  position: absolute;
}

.alt-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--green-dark);
  border: 1px solid var(--green-bright);
  color: var(--beige-light);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

.alt-body {
  padding: 0.9rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.alt-name  { font-size: 0.95rem; font-weight: 700; color: var(--beige-light); }
.alt-brand { font-size: 0.78rem; color: var(--text-dim); font-family: var(--font-mono); }
.alt-desc  { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.2rem; flex: 1; }
.alt-price { font-size: 0.88rem; color: var(--green-bright); font-weight: 600; margin-top: 0.4rem; }

.alt-link {
  display: block;
  text-align: center;
  padding: 0.55rem;
  background: var(--green-dark);
  border-top: 1.5px solid var(--border);
  color: var(--beige-light);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}

.alt-link:hover { background: var(--green-mid); }

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
}

.loading-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.loading-ring {
  width: 64px; height: 64px;
  border: 3px solid rgba(90, 173, 78, 0.15);
  border-top-color: var(--green-bright);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 24px var(--green-glow);
}

.loading-messages { text-align: left; }

.lm {
  font-size: 0.92rem;
  color: var(--text-dim);
  padding: 0.3rem 0;
  transition: all 0.3s;
}

.lm.active {
  color: var(--beige-light);
  font-weight: 600;
}

.lm.done { color: var(--green-bright); }
.lm.done::before { content: '✓ '; }

/* ── SCAN AGAIN ── */
.scan-again-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

.scan-again-wrap .btn-analyze {
  max-width: 300px;
}

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.2rem 2rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ── ERROR STATE ── */
.error-toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 9999;
  animation: fadeInUp 0.3s ease;
  max-width: 90vw;
  text-align: center;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .site-header { padding: 1rem 1.2rem; }
  .tagline { display: none; }
  .input-card { padding: 1.5rem; }
  .input-heading { font-size: 1.4rem; }
  .plastic-identity { flex-direction: column; gap: 1rem; }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .alternatives-grid { grid-template-columns: 1fr; }
  .harm-grid { grid-template-columns: 1fr 1fr; }
  .result-card { padding: 1.3rem; }
}
