/* ================================
   ROOT VARIABLES
   ================================ */
:root {
  --clr-bg: #ffffff;
  --clr-bg-alt: #f7f7f9;
  --clr-surface: #ffffff;
  --clr-border: #e1e1e6;
  --clr-text: #1a1a2e;
  --clr-text-muted: #4b5563;
  --clr-accent: #0d9488;
  --clr-accent-hover: #0f766e;
  --clr-success: #16a34a;
  --clr-growth: #6d28d9;
  --clr-growth-hover: #5b21b6;
  --clr-on-accent: #ffffff;
  --clr-on-success: #1a1a2e;
  --clr-on-growth: #ffffff;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', Courier, monospace;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ================================
   DARK MODE VARIABLES
   ================================ */
[data-theme="dark"] {
  --clr-bg: #0a0f14;
  --clr-bg-alt: #111827;
  --clr-surface: #1f2937;
  --clr-border: #374151;
  --clr-text: #e2e8f0;
  --clr-text-muted: #a1afc4;
  --clr-accent: #2dd4bf;
  --clr-accent-hover: #5eead4;
  --clr-success: #4ade80;
  --clr-growth: #c4b5fd;
  --clr-growth-hover: #ddd6fe;
  --clr-on-accent: #0a0f14;
  --clr-on-success: #0a0f14;
  --clr-on-growth: #0a0f14;
}

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

[hidden] {
  display: none !important;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img,
video {
  max-width: 100%;
  display: block;
}

/* ================================
   SKIP LINK
   ================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  background-color: var(--clr-accent);
  color: var(--clr-on-accent);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
  color: var(--clr-on-accent);
}

/* ================================
   TYPOGRAPHY
   ================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  font-weight: 700;
}

h1 { font-size: clamp(1.75rem, 1.4rem + 1.75vw, 2.75rem); }
h2 { font-size: clamp(1.375rem, 1.1rem + 1.375vw, 2rem); }
h3 { font-size: clamp(1.125rem, 1rem + 0.625vw, 1.5rem); }

p {
  margin-bottom: 1rem;
}

p:last-child {
  margin-bottom: 0;
}

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

a:hover {
  color: var(--clr-accent-hover);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--clr-bg-alt);
  border: 1px solid var(--clr-border);
  border-radius: 0.25rem;
  padding: 0.125em 0.375em;
}

/* ================================
   LAYOUT
   ================================ */
.site-main {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.content-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
  margin-block: 2rem;
  min-width: 0;
}

@media (max-width: 64em) {
  .content-layout {
    grid-template-columns: 1fr;
  }
}

.content-section {
  min-width: 0;
  overflow: hidden;
}

/* ================================
   SITE HEADER
   ================================ */
.site-header {
  border-bottom: 1px solid var(--clr-border);
  padding-block: 1rem;
  background-color: var(--clr-surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__inner {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header__logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--clr-text);
  min-width: 0;
}

.site-header__logo:hover {
  color: var(--clr-accent);
}

.site-header__logo:focus-visible {
  outline: 3px solid var(--clr-accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}

.site-header__logo-icon {
  flex-shrink: 0;
}

.site-header__logo-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================================
   THEME TOGGLE
   ================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: none;
  border: 1px solid var(--clr-border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--clr-text-muted);
  font-size: 1.125rem;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--clr-accent);
  color: var(--clr-accent);
  background-color: var(--clr-bg-alt);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--clr-accent);
  outline-offset: 3px;
}

.theme-toggle__icon--dark {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon--light {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon--dark {
  display: inline;
}

/* ================================
   TOOL SECTION
   ================================ */
.tool-section {
  background-color: var(--clr-bg-alt);
  border-bottom: 1px solid var(--clr-border);
  padding-block: 2.5rem;
}

.tool-section__inner {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.tool-section__title {
  margin-bottom: 0.5rem;
}

.tool-section__description {
  color: var(--clr-text-muted);
  margin-bottom: 2rem;
  max-width: 60ch;
}

/* ================================
   TOOL FORM
   ================================ */
.tool-form {
  display: grid;
  gap: 1.5rem;
}

.tool-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.25rem;
}

.tool-form__grid--single {
  grid-template-columns: minmax(13rem, 24rem);
}

/* ================================
   FORM SECTION
   ================================ */
.form-section {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background-color: var(--clr-surface);
}

.form-section__legend {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.075em;
  color: var(--clr-accent);
  padding-inline: 0.25rem;
}

/* ================================
   FORM GROUP
   ================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text);
}

.form-group__label--required::after {
  content: ' *';
  color: #dc2626;
}

.form-group__input-wrap {
  display: flex;
  align-items: stretch;
}

.form-group__prefix {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background-color: var(--clr-bg-alt);
  border: 1px solid var(--clr-border);
  border-right: none;
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  white-space: nowrap;
  user-select: none;
}

.form-group__input-wrap .form-group__input:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.form-group__input {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--clr-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  background-color: var(--clr-surface);
  color: var(--clr-text);
  transition: border-color 0.15s ease;
  width: 100%;
  flex: 1;
  min-width: 0;
}

.form-group__input-wrap .form-group__input:only-child {
  border-radius: var(--radius);
}

.form-group__input:focus {
  outline: 2px solid var(--clr-accent);
  outline-offset: 2px;
  border-color: var(--clr-accent);
}

.form-group__suffix {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background-color: var(--clr-bg-alt);
  border: 1px solid var(--clr-border);
  border-left: none;
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  white-space: nowrap;
  user-select: none;
}

.form-group__hint {
  font-size: 0.8125rem;
  color: var(--clr-text-muted);
}

/* ================================
   RESULTS
   ================================ */
.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.75rem;
}

.results__card {
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.results__card--survival {
  background-color: var(--clr-surface);
  border: 2px solid var(--clr-accent);
}

.results__card--growth {
  background-color: var(--clr-surface);
  border: 2px solid var(--clr-growth);
}

.results__card-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.results__card--survival .results__card-label {
  color: var(--clr-accent);
}

.results__card--growth .results__card-label {
  color: var(--clr-growth);
}

.results__card-value {
  font-size: clamp(2rem, 1.5rem + 2.5vw, 3rem);
  font-weight: 800;
  line-height: 1;
  color: var(--clr-text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
  word-break: break-word;
}

.results__card-unit {
  font-size: 0.5em;
  font-weight: 600;
  color: var(--clr-text-muted);
  margin-left: 0.125em;
}

.results__card-desc {
  font-size: 0.8125rem;
  color: var(--clr-text-muted);
  margin: 0;
}

@media (max-width: 36em) {
  .results {
    grid-template-columns: 1fr;
  }
}

/* ================================
   BREAKDOWN PANEL
   ================================ */
.breakdown {
  margin-top: 1rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.breakdown__summary {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  cursor: pointer;
  list-style: none;
  background-color: var(--clr-surface);
  transition: background-color 0.15s ease;
}

.breakdown__summary::-webkit-details-marker {
  display: none;
}

.breakdown__summary:hover {
  background-color: var(--clr-bg-alt);
  color: var(--clr-text);
}

.breakdown__summary:focus-visible {
  outline: 3px solid var(--clr-accent);
  outline-offset: -3px;
}

.breakdown__body {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--clr-border);
  background-color: var(--clr-bg-alt);
}

.breakdown__list {
  display: grid;
  gap: 0.5rem;
}

.breakdown__row {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
}

.breakdown__term {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--clr-text-muted);
}

.breakdown__detail {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--clr-text);
}

@media (max-width: 36em) {
  .breakdown__row {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }
}

/* ================================
   CONTENT SECTION
   ================================ */
.content-section {
  padding-block: 2rem 0;
}

.content-section__body h2 {
  margin-bottom: 0.75rem;
  margin-top: 2rem;
}

.content-section__body h2:first-child {
  margin-top: 0;
}

.content-section__body h3 {
  margin-bottom: 0.5rem;
  margin-top: 1.5rem;
}

.content-section__body p {
  color: var(--clr-text);
  max-width: 70ch;
}

.content-section__body ul,
.content-section__body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  max-width: 70ch;
}

.content-section__body li {
  margin-bottom: 0.375rem;
}

/* ================================
   REFERENCE TABLE
   ================================ */
.reference-table {
  width: 100%;
  max-width: 50rem;
  border-collapse: collapse;
  margin-block: 1rem;
  font-size: 0.9375rem;
  display: block;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.reference-table thead,
.reference-table tbody,
.reference-table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.reference-table th,
.reference-table td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  border-bottom: 1px solid var(--clr-border);
}

.reference-table thead th {
  background-color: var(--clr-bg-alt);
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--clr-text-muted);
}

.reference-table tbody tr:hover {
  background-color: var(--clr-bg-alt);
}

.reference-table tbody td {
  color: var(--clr-text);
}

/* ================================
   FAQ SECTION
   ================================ */
.faq-section {
  padding-block: 2.5rem;
  border-top: 1px solid var(--clr-border);
}

.faq-section__inner {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.faq-section__title {
  margin-bottom: 1.5rem;
}

.faq__item {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  margin-bottom: 0.625rem;
  overflow: hidden;
}

.faq__question {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--clr-surface);
  transition: background-color 0.15s ease;
}

.faq__question:hover {
  background-color: var(--clr-bg-alt);
}

.faq__question:focus-visible {
  outline: 3px solid var(--clr-accent);
  outline-offset: -3px;
}

.faq__question::-webkit-details-marker {
  display: none;
}

.faq__question::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 400;
  flex-shrink: 0;
  margin-left: 1rem;
}

details[open] .faq__question::after {
  content: '-';
}

.faq__answer {
  padding: 0 1.25rem 1rem;
  color: var(--clr-text);
  background-color: var(--clr-surface);
}

/* ================================
   SITE FOOTER
   ================================ */
.site-footer {
  background-color: var(--clr-bg-alt);
  border-top: 1px solid var(--clr-border);
  padding-block: 1.5rem;
  margin-top: 3rem;
}

.site-footer__inner {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.site-footer__copy {
  font-size: 0.875rem;
  color: var(--clr-text-muted);
  text-align: center;
}

/* ================================
   RESPONSIVE - TABLET (max 48em / 768px)
   ================================ */
@media (max-width: 48em) {
  .site-main {
    padding-inline: 0;
  }

  .content-layout {
    padding-inline: 1rem;
  }

  .tool-section {
    padding-block: 2rem;
  }

  .results {
    grid-template-columns: 1fr 1fr;
  }

  .ad-slot--inline {
    display: none;
  }

  .ad-slot--leaderboard,
  .ad-slot--rectangle {
    margin-inline: 1rem;
  }
}

/* ================================
   RESPONSIVE - MOBILE (max 36em / 576px)
   ================================ */
@media (max-width: 36em) {
  .tool-section__inner,
  .faq-section__inner {
    padding-inline: 0.75rem;
  }

  .site-header__inner,
  .site-footer__inner {
    padding-inline: 0.75rem;
  }

  .content-layout {
    padding-inline: 0.75rem;
  }

  .ad-slot--leaderboard,
  .ad-slot--rectangle {
    margin-inline: 0.75rem;
  }

  .results {
    grid-template-columns: 1fr;
  }

  .tool-form__grid {
    grid-template-columns: 1fr;
  }

  .faq__question {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
  }

  .faq__answer {
    padding: 0 1rem 0.75rem;
    font-size: 0.9375rem;
  }

  .content-section__body p,
  .content-section__body ul,
  .content-section__body ol {
    max-width: 100%;
  }
}

/* ================================
   REDUCED MOTION
   ================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
