/* =========================================================
   GLOBAL RESET & VARIABLES
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=DM+Sans:wght@400;500&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-2: #F0EEE9;
  --border: #E2DFD8;
  --border-strong: #C8C4BA;
  --text: #1A1915;
  --text-2: #4A4842;
  --text-muted: #8A8680;
  --accent: #1F6FEB;
  --accent-dark: #1557CC;
  --accent-light: #EBF2FF;
  --success: #16A34A;
  --success-light: #DCFCE7;
  --warning: #D97706;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.10), 0 12px 40px rgba(0,0,0,0.06);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   TYPOGRAPHY
   ========================================================= */
h1, h2, h3, h4, h5 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.2rem; }

p { color: var(--text-2); line-height: 1.7; }

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

/* =========================================================
   LAYOUT
   ========================================================= */
.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 780px; margin: 0 auto; padding: 0 20px; }

/* =========================================================
   HEADER / NAV
   ========================================================= */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 1140px;
  margin: 0 auto;
  gap: 24px;
}

.site-logo {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.site-logo .logo-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

.site-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.site-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover { background: var(--surface-2); color: var(--text); }

.header-search {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
  flex: 0 0 220px;
}

.header-search input {
  border: none;
  background: transparent;
  font-size: 0.875rem;
  padding: 8px 0;
  outline: none;
  width: 100%;
  color: var(--text);
  font-family: inherit;
}

.header-search input::placeholder { color: var(--text-muted); }

.search-icon { color: var(--text-muted); flex-shrink: 0; }

/* =========================================================
   HERO / PAGE INTRO
   ========================================================= */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 56px 20px;
  text-align: center;
}

.hero h1 { margin-bottom: 16px; }
.hero p { font-size: 1.1rem; max-width: 580px; margin: 0 auto 32px; }

.hero-search {
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.hero-search:focus-within { border-color: var(--accent); }

.hero-search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 20px;
  font-size: 1rem;
  outline: none;
  font-family: inherit;
  color: var(--text);
}

.hero-search button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.hero-search button:hover { background: var(--accent-dark); }

/* =========================================================
   CATEGORY GRID (Homepage)
   ========================================================= */
.section { padding: 56px 0; }
.section-title { font-size: 1.5rem; margin-bottom: 8px; }
.section-sub { color: var(--text-muted); margin-bottom: 32px; font-size: 0.95rem; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.category-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}

.category-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.category-card h3 { font-size: 1rem; color: var(--text); margin: 0; }
.category-card p { font-size: 0.85rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* Category colours */
.cat-health { background: #FEE2E2; }
.cat-fitness { background: #DCFCE7; }
.cat-finance { background: #EFF6FF; }
.cat-cooking { background: #FEF3C7; }
.cat-home { background: #F3E8FF; }
.cat-diy { background: #FEF9C3; }
.cat-science { background: #E0F2FE; }
.cat-math { background: #F1F5F9; }
.cat-travel { background: #FFF7ED; }
.cat-pets { background: #FCE7F3; }

/* =========================================================
   CALCULATOR GRID
   ========================================================= */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}

.calc-card-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.calc-card-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.calc-card-arrow { color: var(--accent); font-size: 0.85rem; margin-top: auto; font-weight: 500; }

/* =========================================================
   CALCULATOR PAGE LAYOUT
   ========================================================= */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 40px 20px 36px;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--border-strong); }

.page-header h1 { margin-bottom: 10px; }
.page-header .intro-text { font-size: 1.05rem; color: var(--text-2); max-width: 640px; }

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 32px;
  padding: 40px 0;
  align-items: start;
}

/* =========================================================
   CALCULATOR WIDGET
   ========================================================= */
.calc-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: sticky;
  top: 80px;
}

.calc-widget-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  color: white;
}

.calc-widget-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.calc-widget-header p {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  margin: 4px 0 0;
}

.calc-form-body { padding: 24px; }

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

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.field-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  font-family: 'DM Sans', sans-serif;
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
  outline: none;
  -webkit-appearance: none;
}

.field-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.field-input::placeholder { color: var(--text-muted); font-size: 0.85rem; }

select.field-input {
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A8680' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
  appearance: none;
}

textarea.field-input {
  min-height: 100px;
  resize: vertical;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
}

.compute-btn {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 13px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
  letter-spacing: -0.01em;
}

.compute-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.compute-btn:active { transform: translateY(0); }

/* =========================================================
   RESULTS
   ========================================================= */
.calc-results {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.2s;
}

.calc-results.placeholder { opacity: 0.5; }

.placeholder-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px;
}

.result-card {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.result-label {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.result-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.result-text { font-size: 1rem; font-family: 'DM Sans', sans-serif; font-weight: 500; }
.result-unit { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-left: 4px; }

/* =========================================================
   GUIDE / ARTICLE CONTENT
   ========================================================= */
.guide-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  margin-bottom: 24px;
}

.guide-section h2 { margin-bottom: 24px; }
.guide-section h3 { margin: 24px 0 8px; font-size: 1.05rem; }
.guide-section p { color: var(--text-2); line-height: 1.75; }

/* =========================================================
   AFFILIATE BLOCK
   ========================================================= */
.affiliate-block { margin-bottom: 24px; }

.affiliate-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.affiliate-cards { display: flex; flex-direction: column; gap: 10px; }

.affiliate-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none !important;
  color: inherit !important;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.affiliate-card:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,0.15);
}

.affiliate-card-body { flex: 1; min-width: 0; }

.affiliate-card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.affiliate-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.affiliate-card-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.affiliate-amazon-logo {
  font-weight: 900;
  font-size: 0.7rem;
  color: #FF9900;
  letter-spacing: 0.02em;
  font-style: italic;
}

.affiliate-shop-btn {
  background: #FF9900;
  color: #111 !important;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.affiliate-small-print {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 8px;
  opacity: 0.7;
}

/* =========================================================
   ADVANCED OPTIONS TOGGLE
   ========================================================= */
.field-advanced.hidden { display: none; }

.advanced-toggle {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 8px 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  transition: all 0.15s;
}

.advanced-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.advanced-toggle.open { color: var(--accent); border-color: var(--accent); }


/* =========================================================
   RELATED CALCULATORS
   ========================================================= */
.related-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.related-section h3 { margin-bottom: 16px; font-size: 1rem; }

.related-list { display: flex; flex-direction: column; gap: 8px; }

.related-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s;
}

.related-link:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

/* =========================================================
   CATEGORY PAGE HEADER
   ========================================================= */
.cat-page-header {
  padding: 48px 0 40px;
  border-bottom: 1px solid var(--border);
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* =========================================================
   STATS BAR
   ========================================================= */
.stats-bar {
  display: flex;
  gap: 32px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 32px 0;
}

.stat-item { text-align: center; flex: 1; }
.stat-number { font-family: 'JetBrains Mono', monospace; font-size: 1.6rem; font-weight: 600; color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
  background: var(--text);
  color: rgba(255,255,255,0.7);
  padding: 48px 0 32px;
  margin-top: 80px;
}

.footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand .site-logo { color: white; margin-bottom: 12px; display: block; }
.footer-brand p { font-size: 0.85rem; line-height: 1.6; color: rgba(255,255,255,0.5); }

.footer-col h4 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.footer-col a {
  display: block;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 8px;
  text-decoration: none;
  transition: color 0.15s;
}

.footer-col a:hover { color: white; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.35);
  gap: 20px;
  flex-wrap: wrap;
}

.footer-bottom a { color: rgba(255,255,255,0.35); }
.footer-bottom a:hover { color: white; }

.affiliate-disclosure {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
  max-width: 600px;
  line-height: 1.5;
}

/* =========================================================
   SEARCH RESULTS
   ========================================================= */
#search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 200;
  max-height: 360px;
  overflow-y: auto;
  display: none;
}

#search-results.visible { display: block; }

.search-result-item {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: var(--text);
}

.search-result-item:hover { background: var(--bg); }

.search-result-title { font-weight: 600; font-size: 0.9rem; }
.search-result-cat { font-size: 0.75rem; color: var(--text-muted); }
.search-result-icon { font-size: 1.1rem; }

/* =========================================================
   UTILITY
   ========================================================= */
.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--surface-2);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
  .calc-widget { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .stats-bar { flex-wrap: wrap; gap: 16px; }
}

@media (max-width: 640px) {
  .site-nav { display: none; }
  .header-search { flex: 1; }
  .hero { padding: 40px 20px; }
  .calc-form-body { padding: 16px; }
  .guide-section { padding: 24px 20px; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}
