/* Industrial Apple tokens and utilities (no Tailwind build required) */

/* Tokens (OKLCH) */
:root {
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* Z */
  --z-nav: 50;
  --z-popover: 60;
  --z-modal: 70;

  /* Brand (primary) */
  --brand: oklch(0.60 0.08 240);
  --brand-contrast: oklch(0.98 0.01 240);

  /* Tertiary accent */
  --accent: oklch(0.78 0.20 35);
  --accent-contrast: oklch(0.99 0.01 35);

  /* Feedback */
  --success: oklch(0.72 0.14 155);
  --warning: oklch(0.82 0.12 85);
  --danger: oklch(0.62 0.20 25);

  /* Light neutrals */
  --bg: oklch(0.99 0.01 255);
  --bg-2: oklch(0.98 0.01 255);
  --card: oklch(0.98 0.01 255);
  --muted: oklch(0.92 0.02 255);
  --line: oklch(0.86 0.02 255);
  --fg: oklch(0.18 0.02 255);
  /* Secondary text in light should be dark enough for contrast */
  --fg-2: oklch(0.28 0.02 255);

  /* Dark neutrals (darker, near-black) */
  --bg-d: oklch(0.12 0.02 255);
  --bg-2-d: oklch(0.14 0.02 255);
  --card-d: oklch(0.16 0.02 255);
  --muted-d: oklch(0.22 0.02 255);
  --line-d: oklch(0.28 0.02 255);
  --fg-d: oklch(0.93 0.01 255);
  --fg-2-d: oklch(0.88 0.01 255);

  /* Buttons (default: near‑black in light; lighter in dark) */
  --btn-bg: oklch(0.18 0.02 255);
  --btn-fg: oklch(0.98 0.01 255);

  /* Code */
  --code-bg: oklch(0.13 0.02 255);
  --code-fg: oklch(0.94 0.01 255);

  /* Semantic aliases (light default) */
  --background: var(--bg);
  --foreground: var(--fg);
  --surface: var(--card);
  --muted-col: var(--muted);
  --muted-fg: var(--fg-2);
  --border: var(--line);
  --brand-bg: var(--brand);
  --brand-fg: var(--brand-contrast);
}

:root.dark {
  --background: var(--bg-d);
  --foreground: var(--fg-d);
  --surface: var(--card-d);
  --muted-col: var(--muted-d);
  --muted-fg: var(--fg-2-d);
  --border: var(--line-d);
  --btn-bg: oklch(0.28 0.02 255);
  --btn-fg: oklch(0.98 0.01 255);
}

/* Base */
html {
  color-scheme: light dark;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Typography scale */
.s1 {
  font-size: 36px;
  line-height: 44px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

@media (min-width: 768px) {
  .s1 {
    font-size: 44px;
    line-height: 52px;
  }
}

.s2 {
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
}

.s3 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
}

.s4 {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
}

/* Helpers */
.border-1 {
  border-width: 1px;
  border-style: solid;
}

.container-1200 {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.round-sm {
  border-radius: var(--radius-sm);
}

.round-md {
  border-radius: var(--radius-md);
}

.round-lg {
  border-radius: var(--radius-lg);
}

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

/* Brand accent text */
.brand-accent {
  color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  height: 40px;
  line-height: 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid transparent;
}

.btn-primary:hover {
  opacity: .92;
}

/* Focus-visible styles for keyboard users */
.btn:focus-visible,
a.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--brand-bg),
    0 0 0 4px color-mix(in oklch, var(--surface) 100%, transparent);
}

.btn-neutral {
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-neutral:hover {
  background: color-mix(in oklch, var(--muted-col) 30%, transparent);
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid transparent;
}

.btn-accent:hover {
  opacity: .92;
}

/* Theme toggle button */
.btn-toggle {
  min-width: 96px;
  justify-content: center;
}

/* Form controls */
input,
select,
textarea {
  box-sizing: border-box;
}

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.form-control:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--brand),
    0 0 0 4px color-mix(in oklch, var(--surface) 100%, transparent);
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

/* Table shell */
.table-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.table-shell table {
  width: 100%;
  border-collapse: collapse;
}

.table-shell thead th {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--foreground);
  background: color-mix(in oklch, var(--surface) 98%, transparent);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
}

.table-shell tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
}

.table-shell tbody tr:nth-child(even) {
  background: color-mix(in oklch, var(--muted-col) 20%, transparent);
}

.text-right {
  text-align: right;
}

/* Tabular numerals utility */
.tnum {
  font-feature-settings: 'tnum' 1;
}

/* Code */
pre,
code,
kbd,
samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

pre code {
  display: block;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

code.inline {
  background: color-mix(in oklch, var(--muted-col) 60%, transparent);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Header/Footer */
.topnav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
}

.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--fg-2);
}

/* Link focus ring */
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-bg);
  border-radius: var(--radius-sm);
}

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

/* Spacing helpers (8pt scale) */
.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mt-32 {
  margin-top: 32px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.py-24 {
  padding-top: 24px;
  padding-bottom: 24px;
}

.py-40 {
  padding-top: 40px;
  padding-bottom: 40px;
}

.px-16 {
  padding-left: 16px;
  padding-right: 16px;
}

.px-24 {
  padding-left: 24px;
  padding-right: 24px;
}

.gap-16 {
  gap: 16px;
}

.gap-24 {
  gap: 24px;
}

/* Utilities */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.grid {
  display: grid;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hidden {
  display: none;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}