/*
 * base.css — design tokens and primitives shared by every OhMyGold page.
 *
 * Palette is the dark-on-light gold/cream language validated in
 * wireframe/reseller.html. Fonts are a system stack on purpose: the CSP is
 * `style-src 'self'` with no font-src, so there is no Google Fonts and no CDN.
 * The stack below keeps the Manrope/Inter feel (humanist, tight tracking) and
 * the DM Mono/IBM Plex Mono feel (tabular figures) without a network request.
 */

:root {
  /* ink and paper */
  --ink: #162019;
  --ink-2: #4f5b53;
  --muted: #66716a;
  --line: #dce2dd;
  --line-strong: #c6d0c9;
  --paper: #f8faf7;
  --white: #ffffff;

  /* brand */
  --gold: #c6922d;
  --gold-dark: #8b6419;
  --gold-soft: #f6ebd2;
  --forest: #163f2e;
  --forest-2: #235a42;

  /* semantic */
  --green: #1f7a50;
  --green-soft: #e5f4ec;
  --green-line: #bde3ce;
  --red: #b23b32;
  --red-soft: #fae9e7;
  --red-line: #f0c8c4;
  --amber: #9b6b11;
  --amber-soft: #fff3d6;
  --amber-line: #efdaa6;
  --blue: #34496e;
  --blue-soft: #e9eef8;
  --blue-line: #d4deef;
  --violet: #5b21b6;
  --violet-soft: #f5f3ff;
  --violet-line: #ddd6fe;

  --focus: #2563eb;
  --shadow: 0 24px 70px rgba(12, 31, 21, 0.16);
  --shadow-sm: 0 8px 20px rgba(22, 63, 46, 0.09);
  --radius: 18px;
  --radius-sm: 12px;

  /* Minimum comfortable tap target. Every control inherits this. */
  --tap: 44px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

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

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ---------- typography helpers ---------- */

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.muted {
  color: var(--muted);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Hidden state driven only by classes — no inline style attributes anywhere. */
.is-hidden {
  display: none !important;
}

/* ---------- focus ---------- */

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- icons ---------- */

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.i {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.i-sm {
  width: 16px;
  height: 16px;
}

.i-lg {
  width: 26px;
  height: 26px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--muted);
  background: #f4f7f4;
}

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

.btn-primary {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--forest-2);
  border-color: var(--forest-2);
}

.btn-primary:disabled {
  background: #a6afa9;
  border-color: #a6afa9;
  box-shadow: none;
}

.btn-gold {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-dark);
}

.btn-danger {
  color: var(--red);
  border-color: var(--red-line);
  background: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-soft);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--forest);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(22, 63, 46, 0.07);
  border-color: transparent;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--forest);
}

/* ---------- forms ---------- */

.field {
  display: block;
  margin-top: 16px;
}

.field > label,
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="tel"],
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 15px;
}

.field textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.5;
}

.field .hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.field .err {
  display: none;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
}

.field.is-bad input,
.field.is-bad select,
.field.is-bad textarea {
  border-color: var(--red);
}

.field.is-bad .err {
  display: block;
}

.field-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  overflow: hidden;
}

.field-prefix > span {
  display: grid;
  place-items: center;
  padding: 0 12px;
  background: #f1f4f1;
  border-right: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-2);
}

.field-prefix > input {
  border: 0;
  border-radius: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
}

.switch-row .field-label {
  margin-bottom: 2px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
}

.check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--forest);
}

.check-row label {
  font-size: 14px;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  min-height: var(--tap);
  accent-color: var(--gold);
}

/* ---------- cards, panels ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-head .count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: #f1f2f5;
  padding: 2px 8px;
  border-radius: 20px;
}

.panel-head .spacer {
  margin-left: auto;
}

.kv {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  border-bottom: 1px solid #edf0ed;
  font-size: 13px;
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-row > span {
  color: var(--muted);
}

.kv-row > strong {
  text-align: right;
  font-weight: 700;
  word-break: break-word;
}

/* ---------- notices ---------- */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 13px 14px;
  font-size: 13px;
  line-height: 1.5;
}

.notice strong {
  display: block;
}

.notice .code {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.07);
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.03em;
}

.notice-warn {
  background: var(--amber-soft);
  border-color: var(--amber-line);
  color: #6e4c0f;
}

.notice-bad {
  background: var(--red-soft);
  border-color: var(--red-line);
  color: #8a2222;
}

.notice-info {
  background: var(--blue-soft);
  border-color: var(--blue-line);
  color: var(--blue);
}

.notice-ok {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: #14603d;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #f4f4f5;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge .glyph {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.badge-ok {
  background: var(--green-soft);
  color: #065f46;
  border-color: var(--green-line);
}

.badge-warn {
  background: var(--amber-soft);
  color: #92400e;
  border-color: var(--amber-line);
}

.badge-bad {
  background: var(--red-soft);
  color: #991b1b;
  border-color: var(--red-line);
}

.badge-info {
  background: var(--blue-soft);
  color: #1d4ed8;
  border-color: var(--blue-line);
}

.badge-invited {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: var(--violet-line);
}

/* ---------- toasts (aria-live) ---------- */

.toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  background: #18231c;
  color: #ffffff;
  border-radius: 13px;
  padding: 12px 15px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  border-left: 4px solid var(--muted);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.toast-ok {
  border-left-color: #4ade80;
}

.toast-err {
  border-left-color: #ef4444;
}

.toast .code {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: #a8aebc;
}

/* ---------- modal ---------- */

.veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(16, 19, 25, 0.44);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.veil:not(.is-hidden) {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 54px rgba(15, 18, 24, 0.28);
  overflow: hidden;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-body h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.modal-body > p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}

.modal-foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 14px 20px;
  background: #fafbfa;
  border-top: 1px solid var(--line);
}

/* Off-canvas sink used by js/clipboard.js when navigator.clipboard is refused.
   A class, not an inline style, so nothing writes style attributes at runtime. */
.copy-sink {
  position: fixed;
  top: -1000px;
  left: -1000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
}

/* ---------- loading / empty ---------- */

.loading,
.empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.spin {
  animation: spin 0.9s linear infinite;
}

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

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