/* ============================================
   D2 Item Rater — Styles
   Dark Diablo 2 aesthetic: browns, golds, reds
   ============================================ */

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

:root {
  /* D2 Color Palette */
  --bg-dark: #0a0a0c;
  --bg-card: #1a1510;
  --bg-tooltip: #111118;
  --bg-tooltip-border: #3a3226;

  --gold: #c7a44a;
  --gold-bright: #e8d07f;
  --gold-dim: #8b7430;

  --red: #c22020;
  --red-bright: #ff4444;
  --red-dim: #6b1515;

  --green: #00c800;
  --green-dim: #1a7a1a;
  --yellow: #ffff64;
  --yellow-dim: #b5a642;
  --gray: #6b6b6b;
  --gray-light: #9b9b9b;
  --white: #e0d8c8;
  --blue: #6464ff;
  --blue-bright: #8888ff;

  /* Typography */
  --font-display: 'MedievalSharp', cursive;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-tooltip: 'Courier New', Courier, monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-dark);
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;

  /* Subtle dark texture feel */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(139, 116, 48, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(194, 32, 32, 0.04) 0%, transparent 50%);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: var(--space-2xl);
}

a {
  color: var(--gold);
  text-decoration: none;
}
a:hover {
  color: var(--gold-bright);
}

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

.desktop-only { display: none; }
.mobile-only { display: inline; }
div.mobile-only { display: flex; }

@media (min-width: 768px) {
  .desktop-only { display: inline; }
  .mobile-only { display: none; }
  div.mobile-only { display: none; }
}

/* Mobile upload buttons */
.mobile-upload-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}

.mobile-upload-btns .btn {
  flex: 1;
  max-width: 160px;
  font-size: 0.95rem;
  padding: 12px 16px;
}

/* --- Header --- */
.header {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-lg);
}

.logo {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: normal;
  line-height: 1.1;
  margin-bottom: var(--space-sm);
}

.logo-charsi {
  color: var(--gray-light);
  text-shadow: 0 0 20px rgba(107, 107, 107, 0.3);
}

.logo-or {
  color: var(--white);
  font-size: 1.5rem;
  margin: 0 0.15em;
  opacity: 0.6;
}

.logo-gg {
  color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(232, 208, 127, 0.5), 0 0 40px rgba(199, 164, 74, 0.3);
}

.logo-q {
  color: var(--red-bright);
  text-shadow: 0 0 20px rgba(255, 68, 68, 0.4);
}

.tagline {
  font-size: 0.9rem;
  color: var(--gold-dim);
  font-style: italic;
}

/* --- Upload Section --- */
.upload-section {
  margin-bottom: var(--space-lg);
}

.upload-area {
  border: 2px dashed var(--bg-tooltip-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  background: linear-gradient(180deg, rgba(26, 21, 16, 0.6) 0%, rgba(17, 17, 24, 0.6) 100%);
  position: relative;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(199, 164, 74, 0.05) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(26, 21, 16, 0.9) 0%, rgba(17, 17, 24, 0.9) 100%);
}
.upload-area:hover::before,
.upload-area.drag-over::before {
  opacity: 1;
}

.upload-area:active {
  transform: scale(0.99);
}

.upload-icon {
  color: var(--gold-dim);
  margin-bottom: var(--space-md);
  transition: color 0.25s;
}

.upload-area:hover .upload-icon {
  color: var(--gold);
}

.upload-text {
  font-size: 1rem;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.upload-text kbd {
  background: rgba(199, 164, 74, 0.15);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  padding: 2px 6px;
  font-family: var(--font-body);
  font-size: 0.85em;
  color: var(--gold);
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--gray);
}

/* --- Item Type Selector --- */
.item-type-selector {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.item-type-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--bg-tooltip-border);
  border-radius: var(--radius-md);
  color: var(--gray-light);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.item-type-btn:hover {
  border-color: var(--gold-dim);
  color: var(--white);
}

.item-type-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(199, 164, 74, 0.1);
}

/* --- Image Preview --- */
.preview-container {
  margin-top: var(--space-md);
  text-align: center;
}

.preview-container img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-tooltip-border);
  object-fit: contain;
}

.preview-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  justify-content: center;
}

/* --- Buttons --- */
.btn {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: #1a1510;
  box-shadow: 0 2px 8px rgba(199, 164, 74, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  box-shadow: 0 4px 16px rgba(199, 164, 74, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--white);
  border: 1px solid var(--bg-tooltip-border);
}

.btn-secondary:hover {
  border-color: var(--gold-dim);
  background: rgba(58, 50, 38, 0.5);
}

/* --- Loading --- */
.loading-container {
  text-align: center;
  padding: var(--space-2xl) 0;
}

.loading-orb {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(199, 164, 74, 0.2) 0%, transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: orbPulse 2s ease-in-out infinite;
}

.orb-inner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--gold);
  border-right-color: var(--gold-dim);
  animation: orbSpin 1s linear infinite;
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

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

.loading-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.loading-flavor {
  font-size: 0.85rem;
  color: var(--gray);
  font-style: italic;
}

/* --- Result Card --- */
.result-card {
  animation: resultSlideIn 0.5s ease-out;
}

@keyframes resultSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Score Header */
.score-header {
  text-align: center;
  padding: var(--space-lg) 0;
}

.score-emoji {
  font-size: 3.5rem;
  animation: emojiReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes emojiReveal {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-15deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.score-number {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(232, 208, 127, 0.4);
  animation: scoreCount 0.8s ease-out 0.4s both;
}

@keyframes scoreCount {
  from {
    opacity: 0;
    transform: scale(1.5);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

.score-verdict {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: var(--space-xs);
  animation: fadeIn 0.5s ease 0.8s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Verdict colors */
.verdict-trophy { color: var(--gold-bright); text-shadow: 0 0 10px rgba(232, 208, 127, 0.6); }
.verdict-top { color: #88ccff; }
.verdict-wow { color: var(--red-bright); }
.verdict-extra { color: var(--gold); }
.verdict-pvp { color: var(--green); }
.verdict-temp { color: var(--yellow); }
.verdict-charsi { color: var(--gray); }

/* --- D2 Tooltip Card --- */
.tooltip-card {
  background: var(--bg-tooltip);
  border: 1px solid var(--bg-tooltip-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  font-family: var(--font-tooltip);
  font-size: 0.85rem;
  line-height: 1.6;
  position: relative;
  animation: fadeIn 0.5s ease 0.6s both;

  /* D2 tooltip shadow */
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 4px 20px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tooltip-header {
  color: var(--yellow);
  font-weight: bold;
  text-align: center;
  font-size: 0.9rem;
  padding-bottom: var(--space-sm);
}

.tooltip-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bg-tooltip-border), transparent);
  margin: var(--space-sm) 0;
}

/* Mod Rows */
.mod-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.mod-name {
  flex: 1;
}

.mod-value {
  margin-left: var(--space-sm);
  min-width: 50px;
  text-align: right;
}

.mod-points {
  min-width: 45px;
  text-align: right;
  font-weight: bold;
  margin-left: var(--space-sm);
}

/* Point tier colors */
.tier-full .mod-name,
.tier-full .mod-value {
  color: var(--green);
}
.tier-full .mod-points {
  color: var(--green);
}

.tier-half .mod-name,
.tier-half .mod-value {
  color: var(--yellow);
}
.tier-half .mod-points {
  color: var(--yellow);
}

.tier-none .mod-name,
.tier-none .mod-value {
  color: var(--gray);
}
.tier-none .mod-points {
  color: var(--gray);
}

/* Missing Mods */
.section-label {
  color: var(--gold-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.missing-mods ul {
  list-style: none;
  padding: 0;
}

.missing-mods li {
  color: var(--blue-bright);
  padding: 2px 0;
}

.missing-mods li::before {
  content: '+ ';
  color: var(--blue);
}

/* Trade Value */
.trade-value {
  padding-top: var(--space-xs);
}

.trade-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.trade-label {
  color: var(--gray-light);
}

.trade-amount {
  color: var(--gold);
  font-weight: bold;
}

/* --- Result Actions --- */
.result-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  animation: fadeIn 0.5s ease 1s both;
}

.result-actions .btn {
  flex: 1;
  justify-content: center;
}

/* --- Error Card --- */
.error-card {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.error-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.error-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--red-bright);
  margin-bottom: var(--space-sm);
}

.error-message {
  color: var(--gray-light);
  margin-bottom: var(--space-lg);
  font-size: 0.9rem;
}

/* --- History --- */
.history-container {
  margin-top: var(--space-xl);
}

.history-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  user-select: none;
}

.history-title:hover {
  color: var(--gold);
}

.history-arrow {
  transition: transform 0.3s;
  font-size: 0.8rem;
}

.history-arrow.open {
  transform: rotate(180deg);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--bg-tooltip-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: border-color 0.2s;
}

.history-item:hover {
  border-color: var(--gold-dim);
}

.history-emoji {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-score {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1rem;
}

.history-verdict {
  font-size: 0.75rem;
  color: var(--gray);
}

.history-date {
  font-size: 0.7rem;
  color: var(--gray);
  flex-shrink: 0;
}

.history-empty {
  text-align: center;
  color: var(--gray);
  font-size: 0.85rem;
  padding: var(--space-md);
  font-style: italic;
}

/* --- Footer --- */
.footer {
  text-align: center;
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(58, 50, 38, 0.3);
  font-size: 0.75rem;
  color: var(--gray);
}

.footer-sub {
  margin-top: var(--space-xs);
}

/* --- Share Toast --- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* --- Score-specific glow effects --- */
.score-glow-trophy .tooltip-card {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(232, 208, 127, 0.15),
    0 4px 20px rgba(0, 0, 0, 0.6);
}

.score-glow-wow .tooltip-card {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(255, 68, 68, 0.1),
    0 4px 20px rgba(0, 0, 0, 0.6);
}

/* --- Responsive --- */
@media (min-width: 768px) {
  #app {
    max-width: 520px;
    padding: var(--space-lg);
  }

  .logo {
    font-size: 3rem;
  }

  .upload-area {
    padding: var(--space-2xl) var(--space-xl);
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Turnstile hide --- */
#turnstile-container {
  position: fixed;
  bottom: -100px;
  left: -100px;
  opacity: 0;
  pointer-events: none;
}
