/* ═══════════════════════════════════════════════════════════════
   KREDITS — Base and shared components. Every page loads this straight
   after kredits-tokens.css; everything here is built from those tokens.

   Components: .k-brand (logo), .k-btn, .k-link, .k-pill / .k-pill-pro,
   .k-card, .k-icon-tile, .k-icon, .k-input / .k-select, .k-modal*,
   .k-toast, .k-container, .k-h1 / .k-h2 / .k-h3, .k-section-label.
   ═══════════════════════════════════════════════════════════════ */

/* ── BASE ──────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { font-family: var(--font-display); text-wrap: balance; }   /* no one-word last lines */
button, input, select, textarea { font-family: inherit; }
img, svg, video, canvas { max-width: 100%; }

/* One visible focus ring everywhere: keyboard only, never on mouse click. */
:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
:focus:not(:focus-visible) { outline: none; }
/* Many page styles switch the outline off on their fields; keep the ring. */
:is(input, select, textarea):focus-visible { outline: var(--focus-ring) !important; outline-offset: 1px; }

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

/* ── LAYOUT AND TYPE ───────────────────────────────────────── */
.k-container { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
@media (max-width: 480px) { .k-container { padding: 0 var(--space-4); } }
.k-h1 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h1); line-height: var(--leading-h1); letter-spacing: var(--tracking-h1); color: var(--ink); text-wrap: balance; }
.k-h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h2); line-height: var(--leading-h2); letter-spacing: var(--tracking-h2); color: var(--ink); text-wrap: balance; }
.k-h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h3); line-height: var(--leading-h3); color: var(--ink); }
.k-lead { font-size: var(--text-body-lg); line-height: var(--leading-body); color: var(--text-muted); }
.k-section-label {
  font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; margin: 20px 0 8px;
}

/* ── ICONS ─────────────────────────────────────────────────── */
.k-icon {
  width: 1.25em; height: 1.25em; flex-shrink: 0; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.k-icon-tile {
  width: 48px; height: 48px; border-radius: var(--radius-md); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-tint); color: var(--accent);
}
.k-icon-tile .k-icon { width: 24px; height: 24px; }
.k-icon-tile.lg { width: 56px; height: 56px; border-radius: var(--radius-lg); }
.k-icon-tile.lg .k-icon { width: 28px; height: 28px; }
.k-icon-tile.neutral { background: var(--surface-neutral); color: var(--text-muted); }

/* ── LOGO ──────────────────────────────────────────────────────
   <a class="k-brand" href="/"><img src="/icons/k-mark-tight.png" width="30" height="34" alt=""><span>Kredits</span></a> */
.k-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: var(--tap); }
.k-brand img { width: 30px; height: 34px; display: block; }
.k-brand span { font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: -0.01em; line-height: 1; }
.k-brand.sm img { width: 22px; height: 25px; }
.k-brand.sm span { font-size: 21px; }

/* ── BUTTONS AND LINKS ─────────────────────────────────────── */
.k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-family: var(--font-body); font-size: 14px; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.k-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.k-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.k-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.k-btn.lg { min-height: 52px; padding: 14px 24px; border-radius: var(--radius-md); font-size: 16px; }
.k-btn.ghost { border-color: transparent; background: transparent; }
.k-btn.danger { color: var(--danger-text); border-color: var(--danger-border); background: var(--danger-tint); }
.k-btn.danger:hover { color: var(--on-accent); border-color: var(--danger); background: var(--danger); }
.k-btn.full { width: 100%; }
.k-btn:disabled, .k-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none !important; }
.k-btn .k-icon { width: 18px; height: 18px; }
.k-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.k-link:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

/* ── PILLS AND BADGES ──────────────────────────────────────── */
.k-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill);
  background: var(--accent-tint); color: var(--pill-text); font-size: 13px; font-weight: 600; line-height: 1.2;
}
.k-pill-pro {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--on-accent); font-size: 12px; font-weight: 700; letter-spacing: .06em; line-height: 1.3;
}

/* ── CARDS ─────────────────────────────────────────────────── */
.k-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.k-card.lift { transition: transform .2s, box-shadow .2s, border-color .2s; }
.k-card.lift:hover { transform: var(--lift); box-shadow: var(--shadow-hover); }
.k-card.feature { border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.k-card.dashed { border-style: dashed; border-color: var(--border-dashed); }
.k-card-title { font-size: 15px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.k-card-body { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── FORM CONTROLS ─────────────────────────────────────────── */
.k-input, .k-select {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 12px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.k-input::placeholder { color: var(--text-faint); }
.k-input:focus, .k-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint-strong); }
.k-input.mono { font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.k-input.pin { font-family: var(--font-mono); letter-spacing: 0.3em; font-size: 22px; text-align: center; }

/* ── MODALS ─────────────────────────────────────────────────── */
.k-modal-backdrop {
  position: fixed; inset: 0; z-index: 200; padding: 20px;
  background: var(--overlay); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.k-modal-backdrop.open { opacity: 1; pointer-events: all; }
.k-modal {
  width: 100%; max-width: 400px; max-height: min(90vh, 100%); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 26px; box-shadow: var(--shadow-lg);
  transform: translateY(14px); transition: transform .2s;
}
.k-modal-backdrop.open .k-modal { transform: translateY(0); }
.k-modal-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin-bottom: 6px; }
.k-modal-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.5; }
.k-modal-error { font-size: 13px; color: var(--danger-text); min-height: 18px; margin-top: 6px; }
.k-modal-footer { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ── TOAST ─────────────────────────────────────────────────── */
.k-toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(80px); transition: transform .3s cubic-bezier(.4,0,.2,1);
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--on-accent);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); pointer-events: none;
}
.k-toast.show { transform: translateX(-50%) translateY(0); }
.k-toast:empty { visibility: hidden; }
.k-toast.green { background: var(--success-text); }
.k-toast.red   { background: var(--danger-text); }
.k-toast.blue  { background: var(--ink); }

/* ── TAP TARGETS ON PHONES ──────────────────────────────────────
   Every control is at least --tap (44px) on phone widths. :where() keeps
   this at zero specificity so a page's own sizing still wins elsewhere,
   but min-height/min-width override a fixed height. Links inside running
   text are left alone (WCAG inline exception). */
@media (max-width: 600px) {
  :where(button, select, .k-btn,
         input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=hidden])) {
    min-height: var(--tap);
  }
  :where(button, select, .k-btn) { min-width: var(--tap); }
  :where(header, nav, footer) a:where(:not(p a, li p a)),
  :where(.k-link) {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--tap); min-width: var(--tap);
  }
}
