/* Base styles -- the Blueprint contract layer.
 * Styles bare HTML elements using contract custom properties.
 * theme.css overrides the defaults below.
 *
 * Contract vars (set defaults here, override in theme.css):
 *   --color-primary, --color-bg, --color-surface, --color-border
 *   --color-text, --color-text-muted
 *   --color-success, --color-success-bg
 *   --color-danger, --color-danger-bg
 *   --color-warning, --color-warning-bg
 *   --font-sans, --font-mono
 *   --radius, --space-xs, --space-sm, --space-md, --space-lg, --space-xl
 */

:root {
  /* -- Fallback defaults — overridden by theme.css which loads after this file.
     Edit tokens in theme.css, not here. -- */

  /* Font families */
  --font-display: system-ui, sans-serif;
  --font-sans:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    ui-monospace, "Cascadia Code", "Source Code Pro", monospace;

  /* Type scale — change in theme.css to rescale the whole app */
  --text-display:  1.75rem;
  --text-title:    1.375rem;
  --text-heading:  1.125rem;
  --text-body:     1rem;
  --text-body-sm:  0.875rem;
  --text-caption:  0.8125rem;
  --text-micro:    0.75rem;

  /* Colors */
  --color-primary:      #6366f1;
  --color-primary-rgb:  99, 102, 241;
  --color-primary-hover: #4f46e5;
  --color-primary-text:  #ffffff;
  --color-bg:           #ffffff;
  --color-surface:      #f9fafb;
  --color-border:       #e5e7eb;
  --color-text:         #111827;
  --color-text-muted:   #6b7280;

  --color-success:    #16a34a;
  --color-success-bg: #f0fdf4;
  --color-danger:     #dc2626;
  --color-danger-bg:  #fef2f2;
  --color-warning:    #ca8a04;
  --color-warning-bg: #fefce8;
  --color-info:       #2563eb;
  --color-info-bg:    #eff6ff;

  /* Shape */
  --radius:      0.5rem;
  --radius-lg:   1rem;
  --radius-full: 9999px;

  /* Spacing (8px grid) */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 4rem;

  /* Motion */
  --duration-quick:       120ms;
  --duration-normal:      200ms;
  --duration-emphasis:    350ms;
  --duration-celebration: 500ms;
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout — content column width, scales with breakpoints */
  --app-content-width: 420px;

  /* Typography scale multiplier — single hook for app-wide font-size
   * adjustment. Default 1. Set to 1.125 for "larger text", 0.9 for
   * "compact". Every breakpoint's root size is calc(Xpx * var(--font-scale))
   * and every type token is rem, so one variable rescales everything. */
  --font-scale: 1.1;
}

/* Small tablet / large phone landscape (>=600px) */
@media (min-width: 600px) {
  :root { --app-content-width: 500px; }
  html  { font-size: calc(18px * var(--font-scale)); }
}

/* iPad portrait and up (>=768px) */
@media (min-width: 768px) {
  :root { --app-content-width: 560px; }
  html  { font-size: calc(19px * var(--font-scale)); }
}

/* Desktop and up (>=1024px) */
@media (min-width: 1024px) {
  :root { --app-content-width: 640px; }
  html  { font-size: calc(20px * var(--font-scale)); }
}

/* -- Typography -- */
html {
  font-family: var(--font-sans);
  font-size: calc(17px * var(--font-scale));
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark; /* informs the browser's native UI elements */
}

body {
  margin: 0;
  padding: 0;
  font-size: 1rem;
  line-height: 1.6;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  margin-top: 0;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
}
h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-title); }
h3 { font-size: var(--text-heading); }

p  { margin-top: 0; margin-bottom: var(--space-md); }
small { font-size: 0.875rem; }

code, pre { font-family: var(--font-mono); font-size: 0.875em; }
pre {
  overflow-x: auto;
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

/* -- Layout -- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* -- Forms --
   Universal input/select/textarea styling. Excludes type="hidden",
   "checkbox", "radio" (those have their own rules below) — without
   :not(), the universal rule overrides the browser's display:none on
   hidden inputs and they render as visible empty boxes. */
/* The denylist must exclude every non-text input type. Without
 * [type="submit"]/"button"/"reset", buttons match this rule and render
 * as pale form fields. See blueprint base.css.tt for the full reasoning. */
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="file"]),
select,
textarea {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font: inherit;
  color: var(--color-text);
  background: var(--input-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  color: var(--color-text);
}

fieldset { border: none; padding: 0; margin: 0; }

input[type="checkbox"],
input[type="radio"] {
  display: inline-block;
  width: auto;
  margin-right: var(--space-xs);
  vertical-align: middle;
}

/* -- Buttons --
 * appearance: none is mandatory. Without it, macOS Safari + iOS render
 * input[type="submit"] with the system's native button styling, ignoring
 * the background/color set here. See blueprint CLAUDE.md "Rules for LLMs". */
button, [type="submit"], [role="button"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font: inherit;
  font-weight: 500;
  color: var(--color-primary-text);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.15s;
  text-decoration: none;
}

button:hover, [type="submit"]:hover, [role="button"]:hover {
  opacity: 0.9;
  text-decoration: none;
}

button[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover { background: var(--color-surface); }

.btn-danger { background: var(--color-danger); }

/* -- Tables -- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-md);
}

th, td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th { font-weight: 600; }
thead th { border-bottom-width: 2px; }

/* -- Cards (article or .card) -- */
article, .card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

/* -- Nav -- */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
}

nav ul {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

nav a { color: var(--color-text); }
nav a:hover { color: var(--color-primary); text-decoration: none; }

/* -- Flash messages / alerts -- */
[role="alert"] {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-primary);
}

.flash-success, .flash-notice {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
}

.flash-error, .flash-alert {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
}

/* -- Utilities -- */
.text-muted  { color: var(--color-text-muted); }
.text-center { text-align: center; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }

.grid   { display: grid; gap: var(--space-md); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 767px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
