/* ========================================
   BASE.CSS — Design System & Foundation
   Plus Jakarta Sans + Bebas Neue
   ======================================== */

/* Google Fonts loaded via <link> in HTML <head> for non-blocking performance */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.3s ease;
  overflow-x: clip;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }

/* --- Default Tokens --- */
:root {
  color-scheme: light;
  --font-ui: 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --font-score: 'Bebas Neue', sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --speed: 0.25s;
  --speed-slow: 0.4s;

  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --radius-xl: 0;
  --radius-full: 0;

  /* Fallback = tema Terang — default sebelum theme class ter-apply */
  --bg-primary: #f5f3f0;
  --bg-secondary: #eae6e1;
  --bg-hover: #e0dbd5;
  --text-primary: #1a1714;
  --text-secondary: #5c5550;
  --text-muted: #9a938c;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;
  --accent-glow: rgba(37, 99, 235, 0.18);
  --border-color: #d8d3cc;
  --card-bg: #ffffff;
  --card-border: #e8e3dd;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.06);
  --input-bg: #faf9f7;
  --score-color-a: #1e40af;
  --score-color-b: #b91c1c;
  --score-bg: #ffffff;
  --score-shadow: 0 4px 24px rgba(0,0,0,0.08);
  --score-font: var(--font-score);
  --score-glow: none;
  --set-active-bg: var(--accent);
  --set-active-text: #fff;
  --set-bg: #eae6e1;
  --set-text: #7a746e;
  --serve-color: #e67e22;
  --header-bg: rgba(255,255,255,0.85);
  --header-border: #e8e3dd;
  --display-bg: #f5f3f0;
  --btn-secondary-bg: #eee9e4;
  --btn-secondary-text: #3d3832;
  --btn-secondary-hover: #e0dbd5;
  --overlay-bg: rgba(245,243,240,0.92);
}

/* --- Typography --- */
h1 { font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
small { font-size: 0.78rem; color: var(--text-muted); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.25) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.btn:active::after { opacity: 1; transition: opacity 0s; }

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text, #fff);
  box-shadow: 0 2px 8px var(--accent-glow, rgba(0,0,0,0.15));
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 24px var(--accent-glow, rgba(0,0,0,0.2));
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--btn-secondary-bg, transparent);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-color);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,0.2);
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}

.btn svg { width: 18px; height: 18px; pointer-events: none; flex-shrink: 0; }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: var(--radius-md); }
.btn-icon svg { width: 20px; height: 20px; }

/* --- Inputs --- */
.input, .select {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--speed) var(--ease);
  outline: none;
}

.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow, rgba(59,130,246,0.12));
}

.input::placeholder { color: var(--text-muted); font-weight: 400; }

.select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.color-input {
  width: 52px;
  height: 52px;
  padding: 3px;
  border: 2px solid var(--border-color);
  border-radius: 0;
  cursor: pointer;
  background: transparent;
  transition: all var(--speed) var(--ease);
}
.color-input:hover { border-color: var(--accent); transform: scale(1.05); }
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 0; }

/* --- Form --- */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --- Card --- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow, 0 2px 12px rgba(0,0,0,0.06));
  transition: all var(--speed) var(--ease);
  position: relative;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes scorePop {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
@keyframes confettiFall {
  0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes glowPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4); }
}
@keyframes neonFlicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.6; }
}

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

.anim-fade { animation: fadeIn 0.4s var(--ease) both; }
.anim-scale { animation: fadeInScale 0.35s var(--ease) both; }
.anim-score { animation: scorePop 0.35s var(--ease-bounce); }
.anim-pulse { animation: pulse 1.8s ease infinite; }

/* --- Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 6px; }
.gap-sm { gap: 10px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.gap-xl { gap: 32px; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.relative { position: relative; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* --- Theme Picker --- */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  background: var(--input-bg);
  border: 2px solid var(--border-color);
  border-radius: 0;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  letter-spacing: 0.02em;
}

.theme-btn svg { width: 18px; height: 18px; }

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.theme-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text, #fff);
  box-shadow: 0 4px 12px var(--accent-glow, rgba(0,0,0,0.2));
}

/* --- Responsive --- */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .theme-picker { grid-template-columns: repeat(5, 1fr); gap: 6px; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .theme-picker { grid-template-columns: repeat(3, 1fr); }
  .theme-btn { padding: 8px 4px; font-size: 0.55rem; }
}
