/* ============================================
   iLED Calc — Shared Design System (Pure CSS)
   ============================================ */

/* ---- Design Tokens ---- */
:root {
  /* Core Colors */
  --primary: #13c8ec;
  --primary-hover: #0fb8d9;

  --bg-light: #f6f8f8;
  --bg-dark: #101f22;
  --bg-dark-alt: #0a1214;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic Theme Tokens (Light Mode) */
  --bg-body: var(--bg-light);
  --bg-surface: #ffffff;
  --bg-surface-alt: var(--slate-50);
  --text-main: var(--slate-900);
  --text-muted: var(--slate-500);
  --border-color: var(--slate-200);
  --border-muted: var(--slate-100);

  --resistor-body: #d1b38e;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark {
  /* Semantic Theme Tokens (Dark Mode) */
  --bg-body: var(--bg-dark);
  --bg-surface: #1e293b;
  --bg-surface-alt: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-muted: #1e293b;
}

/* ---- Base & Theme ---- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  overflow-x: hidden;
}

html {
  font-family: 'Space Grotesk', sans-serif;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

/* ---- Layout Components ---- */
.l-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.l-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-4);
  width: 100%;
}

@media (min-width: 768px) {
  .l-container {
    padding: 0 var(--space-8);
  }
}

.l-main {
  flex: 1;
  padding: var(--space-8) 0;
}

.l-grid {
  display: grid;
  gap: var(--space-6);
}

.l-sections-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

@media (min-width: 1024px) {
  .l-sections-grid {
    grid-template-columns: repeat(12, 1fr);
  }

  .l-col-7 {
    grid-column: span 7;
  }

  .l-col-6 {
    grid-column: span 6;
  }

  .l-col-5 {
    grid-column: span 5;
  }
}

.l-flex {
  display: flex;
  align-items: center;
}

.l-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Header */
.l-header {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-body);
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
}

.l-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.5rem;
}

.l-footer {
  border-top: 1px solid var(--border-color);
  padding: var(--space-8) 0;
  background: var(--bg-surface-alt);
  margin-top: auto;
  width: 100%;
}

/* ---- UI Components ---- */

/* Cards */
.c-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
  .c-card {
    padding: var(--space-8);
  }
}

.c-card--primary {
  background: var(--primary) !important;
  color: var(--bg-dark) !important;
  border: none !important;
  box-shadow: 0 10px 25px -5px rgba(19, 200, 236, 0.4);
}

.c-card--primary * {
  color: var(--bg-dark) !important;
}

html.dark .c-card--primary h1,
html.dark .c-card--primary h2,
html.dark .c-card--primary h3,
html.dark .c-card--primary h4,
html.dark .c-card--primary p,
html.dark .c-card--primary span,
html.dark .c-card--primary div {
  color: var(--bg-dark) !important;
}

/* Formula Box */
.c-formula-box {
  background: var(--bg-surface-alt);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
}

.c-formula-box p {
  color: var(--text-main);
  text-align: center;
}

/* Forms */
.c-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  opacity: 0.75;
  margin-bottom: var(--space-2);
}

.c-input,
.c-select {
  width: 100%;
  height: 3.25rem;
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

.c-input:focus,
.c-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(19, 200, 236, 0.1);
}

/* Buttons */
.c-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-6);
  height: 3.25rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  font-size: 1rem;
}

.c-btn--primary {
  background: var(--primary);
  color: var(--bg-dark);
}

.c-btn--primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.c-btn--icon {
  width: 3.25rem;
  padding: 0;
  background: var(--bg-surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

/* Navigation */
.c-nav {
  display: flex;
  gap: var(--space-6);
  align-items: center;
}

.c-nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
  padding: var(--space-1) 0;
}

.c-nav-link:hover,
.c-nav-link.active {
  color: var(--primary);
}

.c-nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

/* Mobile Nav */
.mobile-menu-btn {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
}

.mobile-nav {
  display: none;
  width: 100%;
  padding: var(--space-4) var(--space-4) var(--space-6);
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-color);
  position: absolute;
  top: 4.5rem;
  left: 0;
  z-index: 900;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.mobile-nav a {
  display: block;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-muted);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
}

.mobile-nav.open {
  display: flex;
  flex-direction: column;
}

@media (max-width: 1023px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .desktop-nav {
    display: none !important;
  }
}

/* Tables */
.c-table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  width: 100%;
}

.c-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 600px;
}

.c-table th {
  background: var(--bg-surface-alt);
  padding: var(--space-4) var(--space-6);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.c-table td {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-muted);
  font-size: 0.875rem;
}

/* ---- Specific Elements ---- */

/* Resistor Mini Visual */
.mini-resistor {
  position: relative;
  height: 64px;
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: center;
  margin: 0 auto;
}

.mini-resistor-body {
  position: absolute;
  inset: 0;
  background: var(--resistor-body);
  border-radius: var(--radius-full);
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.1);
}

.mini-resistor-bands {
  display: flex;
  justify-content: space-around;
  width: 100%;
  padding: 0 32px;
  z-index: 10;
}

.mini-resistor-bands .rband {
  width: 12px;
  height: 64px;
}

.mini-resistor-lead {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 4px;
  background: #94a3b8;
  transform: translateY(-50%);
  z-index: -1;
}

.mini-resistor-lead.left {
  left: -32px;
}

.mini-resistor-lead.right {
  right: -32px;
}

/* Ohm's Law Triangle */
.c-ohm-triangle {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 320/280;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
}

.c-ohm-triangle-shape {
  position: absolute;
  inset: 0;
  background: var(--slate-800);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.c-ohm-triangle-divider-h {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.c-ohm-triangle-divider-v {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.c-ohm-triangle-content {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  padding: 3rem 0;
}

.ohm-letter {
  background: none;
  border: none;
  color: white;
  font-size: 3rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.ohm-letter.active,
.ohm-letter:hover {
  color: var(--primary);
  text-shadow: 0 0 15px rgba(19, 200, 236, 0.5);
}

/* ---- Responsive Stacking ---- */
@media (max-width: 767px) {

  .l-sections-grid,
  .l-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Utilities */
.u-text-center {
  text-align: center;
}

.u-text-slate-500 {
  color: var(--text-muted);
}

.u-text-primary {
  color: var(--primary);
}

.u-mt-4 {
  margin-top: var(--space-4);
}

.u-mt-8 {
  margin-top: var(--space-8);
}

.u-mt-10 {
  margin-top: var(--space-10);
}

.u-mb-4 {
  margin-bottom: var(--space-4);
}

.u-mb-6 {
  margin-bottom: var(--space-6);
}

.u-mb-8 {
  margin-bottom: var(--space-8);
}

.u-mb-10 {
  margin-bottom: var(--space-10);
}

.u-mb-16 {
  margin-bottom: var(--space-16);
}

.u-font-bold {
  font-weight: 700;
}

.u-font-black {
  font-weight: 900;
}

.u-text-4xl {
  font-size: 2.25rem;
}

.u-text-5xl {
  font-size: 3rem;
}

.u-text-lg {
  font-size: 1.125rem;
}

.u-text-xl {
  font-size: 1.25rem;
}

.u-flex-gap-2 {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.u-flex-gap-3 {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.u-hidden {
  display: none !important;
}

.u-max-w-3xl {
  max-width: 48rem;
  margin: 0 auto;
}