/* ============================================================
   Trennen — Design System
   Typography foundation
   ──────────────────────────────────────────────────────────
   Font stack (load via <link> in each HTML page):
   https://fonts.googleapis.com/css2?
     family=Space+Grotesk:wght@400;600;700
     &family=Inter:ital,wght@0,400;0,500;0,600;1,400
    &family=IBM+Plex+Mono:wght@400;500;600
     &display=swap

   Usage guide
   ───────────
   Space Grotesk 600  →  .wordmark, logo, brand identity
   Space Grotesk 700  →  hero headlines, major marketing headings
   Space Grotesk 400  →  subheadings, large display text

   Inter 400          →  body copy, descriptions, table cells
   Inter 500          →  buttons, nav links, form labels
   Inter 600          →  UI section titles, sidebar labels, emphasis

   IBM Plex Mono 400  →  file names, dimensions, measurements
   IBM Plex Mono 500  →  layer heights, material specs, system values
   IBM Plex Mono 600  →  technical labels and metadata emphasis
   ============================================================ */

/* ── Font family tokens ───────────────────────────────────── */
:root {
  --font-brand:  'Space Grotesk', system-ui, sans-serif;
  --font-ui:     'Inter',         system-ui, sans-serif;
  --font-code:   'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;

  /* Weight tokens */
  --fw-regular:    400;
  --fw-medium:     500;
  --fw-semibold:   600;
  --fw-bold:       700;

  /* ── Premium manufacturing SaaS tokens ─────────────────── */
  --color-bg: #F7F5F0;
  --color-surface: #FFFFFF;
  --color-surface-soft: #FCFBF8;
  --color-text: #191B19;
  --color-text-muted: #6F746E;
  --color-text-soft: #9BA19A;
  --color-border: #E4E6E0;
  --color-border-strong: #CDD3CB;
  --color-primary: #5B875E;
  --color-primary-hover: #466C49;
  --color-primary-soft: #EAF3EA;
  --color-success: #5B875E;
  --color-warning: #C28A35;
  --color-error: #C95A52;
  --color-info: #5A7DBA;

  /* Backward-compatible aliases used across existing pages. */
  --white: var(--color-surface);
  --card: var(--color-surface);
  --off-white: var(--color-bg);
  --bg: var(--color-bg);
  --soft: var(--color-surface-soft);
  --sage: var(--color-primary);
  --sage-light: var(--color-border-strong);
  --sage-dark: var(--color-primary-hover);
  --sage-bg: var(--color-primary-soft);
  --sage-soft: var(--color-primary-soft);
  --sage-line: #BBD2BC;
  --stone: #EEECE6;
  --ink: var(--color-text);
  --ink-2: #2D302C;
  --ink-soft: #343833;
  --muted: var(--color-text-muted);
  --muted-2: var(--color-text-soft);
  --muted-light: var(--color-text-soft);
  --border: var(--color-border);
  --border-light: var(--color-border);
  --border-soft: #EEEDE8;
  --border-2: var(--color-border-strong);
  --line: var(--color-border);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 6px rgba(16,20,16,0.04);
  --shadow: 0 8px 24px rgba(16,20,16,0.05);
  --shadow-md: 0 8px 24px rgba(16,20,16,0.05);
  --shadow-lg: 0 16px 40px rgba(16,20,16,0.06);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base body — Inter Regular ────────────────────────────── */
body {
  font-family: var(--font-ui);
  font-weight: var(--fw-regular);
  font-size: 16px;
  background: var(--off-white);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================================
   BRAND TYPOGRAPHY — Space Grotesk
   ============================================================ */

/* Wordmark / Logo — SemiBold + tracked */
.wordmark,
.brand-wordmark {
  font-family: var(--font-brand);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

/* Hero & major marketing headings — Bold */
h1,
.hero-heading,
.display-heading {
  font-family: var(--font-brand);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: 1.08;
}

/* Section / sub-headings — SemiBold */
h2,
.section-heading {
  font-family: var(--font-brand);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.015em;
  line-height: 1.15;
}

/* Smaller brand headings — Regular */
h3,
.subsection-heading {
  font-family: var(--font-brand);
  font-weight: var(--fw-regular);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* Scale */
.display-2xl { font-size: clamp(3rem, 7vw, 5.5rem); }
.display-xl  { font-size: clamp(2.25rem, 5vw, 3.75rem); }
.display-lg  { font-size: clamp(1.75rem, 3.5vw, 2.75rem); }
.display-md  { font-size: clamp(1.375rem, 2.5vw, 2rem); }
.display-sm  { font-size: 1.25rem; }

/* ============================================================
   UI TYPOGRAPHY — Inter
   ============================================================ */

/* Section titles / UI emphasis — SemiBold */
.ui-title,
.section-title {
  font-family: var(--font-ui);
  font-weight: var(--fw-semibold);
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* Overline labels */
.overline {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Body text */
p,
.body-text {
  font-family: var(--font-ui);
  font-weight: var(--fw-regular);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-2);
}

.body-sm {
  font-size: 13px;
  line-height: 1.6;
}

.body-xs {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

/* ============================================================
   TECHNICAL METADATA — IBM Plex Mono
   ============================================================ */

.docs-body,
.dev-portal,
.api-docs,
.tech-spec {
  font-family: var(--font-code);
  font-weight: var(--fw-regular);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}

.docs-heading {
  font-family: var(--font-code);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.docs-label,
.param-name {
  font-family: var(--font-code);
  font-weight: var(--fw-medium);
  font-size: 13px;
  color: var(--ink);
}

.api-method {
  font-family: var(--font-code);
  font-weight: var(--fw-semibold);
  font-size: 13px;
  letter-spacing: 0.02em;
}

code,
kbd,
pre {
  font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
}

.technical-value,
.file-name,
.dimension-value,
.measurement-value,
.layer-height,
.mono {
  font-family: var(--font-code);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   NAV
   ============================================================ */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 60px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
}

/* Logo wordmark — Space Grotesk SemiBold tracked */
.nav-wordmark {
  font-family: var(--font-brand);
  font-weight: var(--fw-semibold);
  font-size: 17px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}

/* Nav links — Inter Medium */
.nav-links { display: flex; gap: 36px; list-style: none; }
.nav-links a {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms ease;
}
.nav-links a:hover,
.nav-links a.active { color: var(--ink); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--ink);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px;
}

/* ============================================================
   BUTTONS — Inter Medium
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-weight: var(--fw-semibold);
  font-size: 15px;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 200ms ease,
    border-color 200ms ease,
    color 200ms ease,
    box-shadow 200ms ease,
    opacity 200ms ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--sage);
  color: var(--white);
  min-height: 46px;
  padding: 0 24px;
}
.btn-primary:hover {
  background: var(--sage-dark);
  box-shadow: none;
}
.btn-primary.lg   { min-height: 52px; padding: 0 32px; font-size: 16px; }
.btn-primary.full { width: 100%; }

.btn-outline {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--border);
  min-height: 46px;
  padding: 0 24px;
}
.btn-outline:hover { background: var(--soft); border-color: var(--border-2); }

.btn-ghost {
  background: none;
  color: var(--muted);
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--ink); background: var(--sage-bg); }

.btn-sage {
  background: var(--sage);
  color: var(--white);
  min-height: 46px;
  padding: 0 24px;
}
.btn-sage:hover { background: var(--sage-dark); }

.btn-danger {
  background: #DC2626;
  color: var(--white);
  height: 40px;
  padding: 0 20px;
}
.btn-danger:hover { background: #B91C1C; }

.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.38; pointer-events: none; }

/* ============================================================
   FORMS — Inter
   ============================================================ */

.form-group { display: flex; flex-direction: column; gap: 6px; }

/* Labels — Inter SemiBold */
.form-label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--ink-2);
  letter-spacing: 0.03em;
}

/* Inputs — Inter Regular */
.form-input,
.form-select,
.form-textarea {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: var(--fw-regular);
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px;
  width: 100%;
  height: 40px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17,19,23,0.08);
}
.form-textarea { resize: vertical; min-height: 100px; height: auto; line-height: 1.55; }
.form-input::placeholder,
.form-textarea::placeholder { color: var(--muted-light); }
.form-hint  { font-family: var(--font-ui); font-size: 12px; color: var(--muted); line-height: 1.5; }
.form-error { font-family: var(--font-ui); font-size: 12px; color: #DC2626; }

/* Grid helpers */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid-2 .col-span-2 { grid-column: span 2; }

/* ============================================================
   BADGES — Inter SemiBold
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  line-height: 1.6;
}
.badge-sage  { color: var(--sage-dark);  background: var(--sage-bg);  border: 1px solid var(--sage-light); }
.badge-stone { color: var(--muted);      background: var(--off-white);       border: 1px solid var(--border-light); }
.badge-green { color: var(--color-success); background: var(--sage-bg);      border: 1px solid var(--sage-light); }
.badge-amber { color: var(--color-warning); background: rgba(194,138,53,0.10); border: 1px solid rgba(194,138,53,0.24); }
.badge-red   { color: var(--color-error);   background: rgba(201,90,82,0.10);  border: 1px solid rgba(201,90,82,0.24); }
.badge-blue  { color: var(--color-info);    background: rgba(90,125,186,0.10); border: 1px solid rgba(90,125,186,0.24); }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */

.toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 200ms ease;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 14px; height: 14px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-track { background: var(--sage); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--sage); outline-offset: 2px; }

/* ============================================================
   RADIO CARDS
   ============================================================ */

.radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
  background: var(--white);
  font-family: var(--font-ui);
}
.radio-card:hover { border-color: var(--ink-2); }
.radio-card.selected {
  border-color: var(--ink);
  background: rgba(17,19,23,0.03);
}

/* ============================================================
   CHIP
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  background: var(--white);
}

/* ============================================================
   TAG INPUT (colours / finishes)
   ============================================================ */

.tag-input-wrapper {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; min-height: 40px; background: var(--white);
  cursor: text; transition: border-color 150ms ease, box-shadow 150ms ease;
}
.tag-input-wrapper:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17,19,23,0.08);
}
.tag-item {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--off-white); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 2px 8px;
  font-family: var(--font-ui); font-size: 12px; color: var(--ink);
}
.tag-remove {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; line-height: 1; padding: 0;
  transition: color 150ms;
}
.tag-remove:hover { color: #DC2626; }
.tag-text-input {
  border: none; outline: none; background: transparent;
  font-family: var(--font-ui); font-size: 13px; color: var(--ink);
  min-width: 140px; flex: 1;
}

/* ============================================================
   QUANTITY CONTROL
   ============================================================ */

.qty-control {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.qty-btn {
  width: 36px; height: 36px;
  background: var(--white); border: none; cursor: pointer;
  font-size: 18px; font-weight: var(--fw-regular);
  color: var(--muted); font-family: var(--font-ui);
  transition: background 150ms, color 150ms;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { background: var(--off-white); color: var(--ink); }
.qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.qty-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
.qty-display {
  width: 44px; text-align: center;
  font-family: var(--font-ui); font-size: 14px; font-weight: var(--fw-medium);
  color: var(--ink); background: var(--white); border: none; outline: none; padding: 0 4px;
}
.qty-display::-webkit-inner-spin-button,
.qty-display::-webkit-outer-spin-button { -webkit-appearance: none; }
.qty-display[type=number] { -moz-appearance: textfield; }

/* ============================================================
   DIVIDER
   ============================================================ */

hr.divider { border: none; border-top: 1px solid var(--border-light); margin: 24px 0; }

/* ============================================================
   AUTH PAGES
   ============================================================ */

.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--off-white); padding: 40px 20px;
}
.auth-wordmark {
  font-family: var(--font-brand);
  font-weight: var(--fw-semibold);
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink); text-decoration: none;
  margin-bottom: 36px; display: block; text-align: center;
}
.auth-card {
  background: var(--white); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 36px 32px;
}
.auth-title {
  font-family: var(--font-brand);
  font-weight: var(--fw-semibold);
  font-size: 22px; letter-spacing: -0.01em;
  color: var(--ink); margin-bottom: 6px;
}
.auth-subtitle { font-family: var(--font-ui); font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.auth-error {
  background: rgba(153,27,27,0.06);
  border: 1px solid rgba(153,27,27,0.20);
  border-radius: var(--radius);
  padding: 10px 14px; font-family: var(--font-ui); font-size: 13px; color: #991B1B;
  margin-bottom: 16px; display: none;
}
.auth-error.visible { display: block; }

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 280ms ease-out; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fade-in { animation: fadeIn 220ms ease-out; }

/* ============================================================
   RESPONSIVE — mobile nav
   ============================================================ */

@media (max-width: 640px) {
  .nav { padding: 0 20px; }
  .nav-links {
    display: none; position: fixed;
    top: 60px; left: 0; right: 0;
    background: var(--white); border-bottom: 1px solid var(--border-light);
    flex-direction: column; padding: 28px 24px; gap: 24px; z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-links.open a { font-size: 15px; }
  .nav-toggle { display: block; }

  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 .col-span-2 { grid-column: span 1; }
}
