/* ============================================
   calcswim Design System
   Clean, professional calculator site
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* --- CSS Custom Properties --- */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --primary-surface: #f0f6ff;
  --teal: #00897b;
  --teal-light: #e0f2f1;
  --green: #0d904f;
  --green-light: #e6f4ea;
  --red: #d93025;
  --red-light: #fce8e6;
  --orange: #e8710a;
  --orange-light: #fef7e0;
  --purple: #7c3aed;
  --purple-light: #f3e8ff;

  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #80868b;
  --text-inverse: #ffffff;

  --bg-body: #f8f9fa;
  --bg-white: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #f1f3f4;
  --bg-dark: #202124;

  --border-color: #dadce0;
  --border-light: #e8eaed;
  --border-focus: var(--primary);

  --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
  --shadow-md: 0 1px 3px rgba(60,64,67,0.15), 0 4px 8px rgba(60,64,67,0.1);
  --shadow-lg: 0 1px 3px rgba(60,64,67,0.1), 0 8px 24px rgba(60,64,67,0.12);
  --shadow-xl: 0 4px 12px rgba(60,64,67,0.1), 0 16px 40px rgba(60,64,67,0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --container: 1140px;
  --header-height: 64px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-secondary);
  background: var(--bg-body);
  line-height: 1.6;
  font-size: 16px;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-dark); }
ul, ol { list-style: none; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.25;
  font-weight: 700;
}
h1 { font-size: 2.25rem; letter-spacing: -0.025em; }
h2 { font-size: 1.625rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
p { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }

/* --- Layout --- */
.container {
  width: min(var(--container), calc(100% - 2rem));
  margin: 0 auto;
}
.page-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 960px) {
  .page-grid { grid-template-columns: 1fr; }
}

/* --- Header --- */
.site-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}
.header-inner {
  width: min(var(--container), calc(100% - 2rem));
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}
.logo:hover { color: var(--text-primary); }
.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 1.1rem;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.header-nav a {
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}
.header-nav a:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.header-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
}
.header-search {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border-radius: var(--radius-xl);
  padding: 0 1rem;
  gap: 0.5rem;
  max-width: 280px;
  flex: 1;
}
.header-search input {
  border: none;
  background: transparent;
  padding: 0.5rem 0;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  width: 100%;
  outline: none;
}
.header-search svg { flex-shrink: 0; color: var(--text-tertiary); }
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text-secondary);
}
@media (max-width: 768px) {
  .header-nav { display: none; }
  .header-search { display: none; }
  .mobile-menu-btn { display: flex; }
  .header-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
  }
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  padding: 1rem 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs span { margin: 0 0.375rem; }

/* --- Hero Section (Calculator Pages) --- */
.calc-hero {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  padding: 2rem 0 2.5rem;
}
.calc-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-xl);
  margin-bottom: 0.75rem;
}
.calc-hero h1 { margin-bottom: 0.75rem; }
.calc-hero .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 700px;
  line-height: 1.7;
}

/* --- Calculator Widget --- */
.calc-widget {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  animation: fadeSlideUp 0.4s ease;
}
.calc-widget-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.calc-widget-title svg {
  color: var(--primary);
  flex-shrink: 0;
}

/* --- Form Fields --- */
.field-group {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.field label, .field > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.field small {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 400;
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap .unit {
  position: absolute;
  right: 0.875rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-tertiary);
  pointer-events: none;
}
.input-wrap .unit-left {
  position: absolute;
  left: 0.875rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-tertiary);
  pointer-events: none;
}
input[type="number"],
input[type="text"],
input[type="date"],
select {
  width: 100%;
  height: 44px;
  padding: 0 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
input.has-unit-right { padding-right: 3rem; }
input.has-unit-left { padding-left: 2rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 44px;
  padding: 0 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--border-light); color: var(--text-primary); }
.btn-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* --- Result Display --- */
.calc-result {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--primary-surface);
  border: 1px solid rgba(26,115,232,0.2);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.3s ease;
}
.calc-result-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}
.calc-result-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.calc-result-detail {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  line-height: 1.6;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.result-item {
  text-align: center;
  padding: 1rem;
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}
.result-item .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.result-item .value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 0.25rem;
}
.result-green { border-left: 4px solid var(--green); background: var(--green-light); }
.result-green .calc-result-label { color: var(--green); }
.result-orange { border-left: 4px solid var(--orange); background: var(--orange-light); }
.result-orange .calc-result-label { color: var(--orange); }

/* --- Content Sections --- */
.content-section {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.content-section h2 {
  font-size: 1.375rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.content-section h3 {
  font-size: 1.1rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}
.content-section p {
  color: var(--text-secondary);
  line-height: 1.75;
}
.content-section ul, .content-section ol {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}
.content-section li {
  list-style: disc;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  line-height: 1.65;
}
.content-section ol li { list-style: decimal; }

/* --- Formula Display --- */
.formula-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
  text-align: center;
}
.formula {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Cambria Math', 'Times New Roman', serif;
  letter-spacing: 0.02em;
}
.formula-caption {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

/* --- FAQ Accordion --- */
.faq-section { margin-top: 0; }
.faq-item {
  border-bottom: 1px solid var(--border-light);
}
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  background: none;
  border: none;
  padding: 1rem 0;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: color var(--transition-fast);
}
.faq-question:hover { color: var(--primary); }
.faq-question svg {
  flex-shrink: 0;
  transition: transform var(--transition-base);
  color: var(--text-tertiary);
}
.faq-item.open .faq-question svg { transform: rotate(180deg); }
.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base), padding var(--transition-base);
}
.faq-item.open .faq-answer {
  max-height: 500px;
  padding-bottom: 1rem;
}
.faq-answer p {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* --- Related Calculators --- */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.related-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.related-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.related-card .icon {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* --- Sidebar --- */
.sidebar-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.sidebar-card h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
  transition: color var(--transition-fast);
}
.sidebar-list a:last-child { border-bottom: none; }
.sidebar-list a:hover { color: var(--primary); }
.sidebar-list .dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Homepage --- */
.home-hero {
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  color: white;
  padding: 4rem 0;
  text-align: center;
}
.home-hero h1 {
  color: white;
  font-size: 2.75rem;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}
.home-hero p {
  color: rgba(255,255,255,0.88);
  font-size: 1.2rem;
  max-width: 600px;
  margin: 0 auto 2rem;
}
.home-search {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  background: white;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}
.home-search input {
  border: none;
  flex: 1;
  height: 56px;
  padding: 0 1.5rem;
  font-size: 1.05rem;
  border-radius: 0;
}
.home-search input:focus { box-shadow: none; }
.home-search button {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0 1.5rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.home-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 2rem;
}
.home-stat {
  text-align: center;
}
.home-stat .num {
  font-size: 1.75rem;
  font-weight: 900;
  color: white;
}
.home-stat .lbl {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
}

/* --- Category Grid --- */
.categories-section {
  padding: 3rem 0;
}
.categories-section > .container > h2 {
  text-align: center;
  margin-bottom: 0.5rem;
}
.categories-section > .container > p {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.category-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: all var(--transition-base);
  text-decoration: none;
  display: block;
}
.category-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.category-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 0.875rem;
}
.category-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.375rem;
  color: var(--text-primary);
}
.category-card p {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin: 0;
}
.category-card .count {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xl);
}

/* --- Calculator List (Category Pages) --- */
.calc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.calc-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.calc-list-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(3px);
}
.calc-list-item h4 {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}
.calc-list-item p {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin: 0;
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-dark);
  color: rgba(255,255,255,0.7);
  padding: 3rem 0 1.5rem;
  margin-top: 3rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}
.footer-col h4 {
  color: white;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.footer-col a {
  display: block;
  padding: 0.25rem 0;
  color: rgba(255,255,255,0.6);
  font-size: 0.875rem;
  transition: color var(--transition-fast);
}
.footer-col a:hover { color: white; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.fade-in { animation: fadeIn 0.4s ease; }
.fade-slide-up { animation: fadeSlideUp 0.4s ease; }

/* --- Utility Classes --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* --- Print Styles --- */
@media print {
  .site-header, .site-footer, .sidebar-card, .related-grid, .breadcrumbs { display: none !important; }
  .page-grid { grid-template-columns: 1fr; }
  .calc-widget { box-shadow: none; border: 1px solid #ccc; }
  body { background: white; }
}
