/* Базові стилі: скидання, типографіка, «голі» елементи форм (щоб успадковані інтерфейси модулів
   одразу виглядали в єдиному стилі), прокрутка, виділення, фокус. */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 15.5px; font-weight: 650; }
h4 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 .8em; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
small { font-size: 12px; }
code, kbd, samp { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 1px 5px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.bw-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

::selection { background: var(--primary-line); color: var(--text); }

/* фокус: кільце лише для клавіатури */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* прокрутка */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; border: 2px solid transparent; }

/* ---------- голі елементи форм ---------- */
button, input, select, textarea { font: inherit; color: inherit; }

input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="email"],
input[type="url"], input[type="date"], input[type="time"], input:not([type]), select, textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: 36px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast);
}
textarea { min-height: 72px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; background: var(--surface-2); }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b819d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 16px;
  cursor: pointer;
}
select[multiple] { background-image: none; padding-right: 11px; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; cursor: pointer; }
input[type="range"] { accent-color: var(--primary); }
input[type="color"] { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 2px; background: var(--surface); height: 36px; cursor: pointer; }
input[type="file"] { font-size: 13px; color: var(--text-2); }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 13px; margin-right: 10px; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 12px;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-3); }

/* кнопки без класу виглядають як вторинні; варіанти - у components.css */
button {
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  min-height: 34px;
  font-weight: 550;
  font-size: 13.5px;
  line-height: 1.2;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease), color var(--t-fast);
}
button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

table { border-collapse: collapse; }

label { color: var(--text-2); }

/* корисні утиліти */
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.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; }

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

/* ---------- сенсорні екрани: зручні цілі натискання, 16px у полях (iOS не збільшує сторінку при фокусі) ---------- */
@media (pointer: coarse) {
  input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="email"],
  input[type="url"], input[type="date"], input[type="time"], input:not([type]), select, textarea { font-size: 16px; min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  button { touch-action: manipulation; }
}
