/* ============================================================
 * base.css — Reset, typography, and global element defaults
 *
 * - CSS reset / box-sizing
 * - html/body baseline (font-family, line-height, color, bg)
 * - Heading and paragraph rhythm
 * - Form-control normalization
 * - Selection / focus-visible defaults
 *
 * Uses only variables defined in tokens.css.
 * Filled in task 11.2.
 *
 * Validates: Requirements 11.7, 12.9, 13.6
 * ============================================================ */

/* ─── Modern reset ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  /* dvh is preferred on iOS to track the dynamic viewport (Req. 12.10). */
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-1);
  background: var(--bg-0);
  overflow: hidden; /* App owns scroll containers (chat-view, sidebar lists). */
}

/* Remove list styles on lists with explicit role="list" (Sidebar / Cards). */
ul[role="list"],
ol[role="list"] {
  list-style: none;
}

/* Inherit fonts on form controls. */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
          appearance: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--brand-1);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

textarea {
  resize: none;
  font-family: var(--font-ui);
}

/* Hide native search "x" — we use a custom design. */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

/* ─── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-tight);
  font-weight: 600;
  color: var(--text-1);
}

h1 { font-size: var(--font-size-xl); }
h2 { font-size: var(--font-size-lg); }
h3 { font-size: var(--font-size-md); }

p {
  line-height: var(--line-height-base);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

::selection {
  background: var(--brand-1);
  color: var(--text-on-accent);
}

/* ─── Focus styling ───────────────────────────────────────────────────────
 * Requirement 13.6: visible focus outline ≥2px on all interactive elements.
 * Use focus-visible so keyboard users get an outline while pointer users
 * don't. Outline + offset + box-shadow gives a halo visible on any bg.
 * ────────────────────────────────────────────────────────────────────── */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

/* No-script fallback already styled inline; nothing to do. */

/* Hidden but accessible utility. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
