/* ==========================================================================
 * base.css — design tokens, reset, typography and form primitives.
 * ========================================================================== */

:root {
  /* surfaces */
  --bg:            #21201d;
  --bg-elevated:   #262421;
  --surface:       #302e2b;
  --surface-2:     #3a3835;
  --surface-3:     #46443f;
  --border:        rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .14);

  /* text */
  --text:   #f4f4f3;
  --text-2: #b6b4b1;
  --text-3: #85837f;

  /* brand */
  --accent:       #81b64c;
  --accent-hover: #97ce5c;
  --accent-press: #6b9a3d;
  --accent-soft:  rgba(129, 182, 76, .14);
  --accent-ink:   #14200a;
  /* the accent as *text*: readable on the surface behind it */
  --accent-text:  #97ce5c;

  /* semantic */
  --danger:  #e0574d;
  --warning: #e8a33d;
  --info:    #5f9ed6;

  /* move classification */
  --c-brilliant:  #26c2a3;
  --c-great:      #749bbf;
  --c-best:       #81b64c;
  --c-excellent:  #83b657;
  --c-good:       #95b776;
  --c-book:       #a88865;
  --c-inaccuracy: #f0c15c;
  --c-mistake:    #e8944a;
  --c-miss:       #d76b6b;
  --c-blunder:    #ca3431;

  /* geometry */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow:    0 4px 14px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .45);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --header-h: 60px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* Light theme — the whole app re-skins from these. */
:root[data-theme="light"] {
  --bg:            #f2f1ef;
  --bg-elevated:   #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f1efec;
  --surface-3:     #e4e1dc;
  --border:        rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .16);
  --text:          #21201d;
  --text-2:        #56534e;
  --text-3:        #85837f;
  --accent-ink:    #ffffff;
  --accent-text:   #4a7328;
  --accent-soft:   rgba(129, 182, 76, .18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .1);
  --shadow:    0 4px 14px rgba(0, 0, 0, .12);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .18);
}

/* --------------------------------------------------------------- reset -- */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; letter-spacing: -.01em; }
h3 { font-size: 1.1rem; }
h4 { font-size: .95rem; }
p  { margin: 0 0 .75em; }
a  { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ scrollbar -- */

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* -------------------------------------------------------------- buttons -- */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  appearance: none;
  border: none;
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .14s var(--ease), transform .08s var(--ease),
              box-shadow .14s var(--ease), opacity .14s var(--ease);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  user-select: none;
}
.btn:hover  { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  box-shadow: 0 3px 0 var(--accent-press), var(--shadow-sm);
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { box-shadow: 0 1px 0 var(--accent-press); transform: translateY(2px); }

.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; }
.btn-danger:hover { background: #ec6b61; }

.btn-ghost {
  --btn-bg: transparent;
  box-shadow: none;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-lg { padding: 14px 26px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 38px; height: 38px; border-radius: var(--radius); }
.btn-icon svg { width: 20px; height: 20px; }

/* --------------------------------------------------------------- inputs -- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-2); }

.input, .select, textarea.input {
  appearance: none;
  width: 100%;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 11px 13px;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2385837f' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 34px;
  cursor: pointer;
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 40px; height: 23px;
  background: var(--surface-3);
  border-radius: 99px;
  position: relative;
  transition: background .16s var(--ease);
  flex: none;
}
.switch .track::after {
  content: '';
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 17px;
  background: var(--text-2);
  border-radius: 50%;
  transition: transform .16s var(--ease), background .16s var(--ease);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }

/* ---------------------------------------------------------------- misc --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .01em;
}

.muted    { color: var(--text-2); }
.dim      { color: var(--text-3); }
.mono     { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden   { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.spacer { flex: 1; }
.stack  { display: flex; flex-direction: column; gap: 12px; }
.row    { display: flex; align-items: center; gap: 10px; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  0%   { opacity: 0; transform: scale(.94); }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
