/* ==========================================================================
   CalcHub Design System — Clean, Warm, Editorial
   ========================================================================== */

:root {
  /* Clean palette with blue accent */
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1060px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.03);
  --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.logo span {
  color: var(--text);
}

.nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav a:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.nav a.active {
  color: #fff;
  background: var(--accent);
  font-weight: 600;
}

/* ==========================================================================
   Main Container
   ========================================================================== */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px;
  width: 100%;
  flex: 1;
}

/* ==========================================================================
   Hero Section (Landing Page)
   ========================================================================== */

.hero {
  text-align: center;
  padding: 48px 16px 32px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
  color: var(--text);
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  line-height: 1.6;
  max-width: 560px;
  margin: 0 auto;
}

/* ==========================================================================
   Card Grid (Landing Page)
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 32px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

.card-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.card > p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.card .card-links {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card .card-links a {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 8px;
  background: var(--accent-light);
  border-radius: 999px;
}

.card .card-links a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Calculator Page Layout
   ========================================================================== */

.calc-page {
  max-width: 680px;
  margin: 0 auto;
}

.calc-page h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 6px;
}

.calc-page .subtitle,
.calc-page .calc-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 0.9375rem;
}

/* ==========================================================================
   Calculator Form (Pattern B: material, tile, wallpaper)
   ========================================================================== */

.calc-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.8125rem;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.form-group .hint {
  font-weight: 400;
  color: var(--text-tertiary);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* ==========================================================================
   Two-Column Calculator Layout
   ========================================================================== */

.calc-two-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calc-two-col__left,
.calc-two-col__right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   Calculator Grid (Pattern A: paint, electricity)
   ========================================================================== */

.calc-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.calc-card h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
  color: var(--text);
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-weight: 500;
  font-size: 0.8125rem;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Results card (Pattern A) */
.results-card {
  display: none;
  background: var(--success-bg);
  border-color: var(--success-border);
}

.results-card.visible {
  display: block;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--success-border);
  font-size: 0.875rem;
}

.result-row:last-child {
  border-bottom: none;
}

.result-row span,
.result-row .result-label {
  color: var(--text-secondary);
}

.result-row strong,
.result-row .result-value {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

/* ==========================================================================
   Form Controls
   ========================================================================== */

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

input::placeholder {
  color: var(--text-tertiary);
}

/* Remove number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 24px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease;
  width: 100%;
  background: var(--accent);
  color: #fff;
  letter-spacing: -0.01em;
  margin-top: 6px;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  font-size: 0.8125rem;
}

.btn-secondary:hover {
  background: var(--accent-light);
  border-color: #ccc;
}

/* ==========================================================================
   Results Section (Pattern B: material, tile, wallpaper)
   ========================================================================== */

.results {
  margin-top: 16px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: none;
}

.results.visible {
  display: block;
}

.results h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
  color: var(--success);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--success-border);
}

.result-item .label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.result-item .value {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.result-item .unit {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  font-family: var(--font);
}

/* ==========================================================================
   Tips Section
   ========================================================================== */

.tips,
.info-section {
  margin-top: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.tips h2,
.info-section h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

.tips ul,
.info-section ul {
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.tips li,
.info-section li {
  margin-bottom: 8px;
}

.tips li:last-child,
.info-section li:last-child {
  margin-bottom: 0;
}

.info-section a {
  color: var(--accent);
  text-decoration: none;
}

.info-section a:hover {
  text-decoration: underline;
}

/* Tips card (paint calculator pattern) */
.calc-card.tips-card {
  background: var(--bg-card);
}

.calc-card.tips-card ul,
.calc-card ul {
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.calc-card.tips-card li,
.calc-card li {
  margin-bottom: 8px;
}

.calc-card a {
  color: var(--accent);
  text-decoration: none;
}

.calc-card a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Related Calculators
   ========================================================================== */

.related {
  margin-top: 16px;
}

.related h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.related-links a {
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background var(--transition);
}

.related-links a:hover {
  background: var(--accent-light);
}

/* ==========================================================================
   Ad Slots
   ========================================================================== */

.ad-slot {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
  margin: 20px auto;
  max-width: var(--max-width);
  min-height: 80px;
  text-align: center;
}

.ad-slot--banner {
  min-height: 80px;
}

.ad-slot--responsive {
  min-height: 90px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 14px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (min-width: 640px) {
  .result-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .calc-grid {
    flex-direction: row;
    align-items: flex-start;
  }

  .calc-grid > .calc-card {
    flex: 1;
  }

  .calc-two-col {
    flex-direction: row;
    align-items: flex-start;
  }

  .calc-two-col__left {
    flex: 1;
    min-width: 0;
  }

  .calc-two-col__right {
    flex: 1;
    min-width: 0;
  }
}

@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  .calc-page h1 {
    font-size: 1.75rem;
  }

  .container {
    padding: 40px 24px;
  }
}

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

  .header-inner {
    height: 60px;
  }

  .nav a {
    font-size: 0.875rem;
    padding: 6px 14px;
  }
}

/* ==========================================================================
   Utility
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Global visible override for inline display:none */
[style*="display:none"].visible,
[style*="display: none"].visible {
  display: block !important;
}
