/* ==========================================================================
   ClarumMare Zero-Touch Web Factory — Core Stylesheet
   AdSense-compliant, mobile-first, zero-CLS design system
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #0369a1;
  --primary-hover: #075985;
  --primary-soft: #e0f2fe;
  --accent: #0284c7;
  --success: #047857;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --header-height: 64px;
  --container-max: 920px;
  --font-sans: "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo",
    "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a:hover {
  text-decoration: underline;
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #ffffff;
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  border-radius: var(--radius-sm);
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header (Fixed height for zero CLS) */
.site-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.site-brand:hover {
  text-decoration: none;
  color: var(--primary);
}

.site-brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 800;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.125rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.site-nav a {
  color: var(--text-secondary);
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--primary);
  text-decoration: none;
}

/* Main Content */
.site-main {
  flex: 1 0 auto;
  padding: 1.25rem 0 2.5rem;
}

/* ==========================================================================
   AdSense Zero-CLS Containers
   Fixed minimum heights prevent Cumulative Layout Shift during ad loading.
   Clear spacing separates ad units from interactive controls per AdSense policy.
   ========================================================================== */
.ad-container {
  margin: 1.25rem auto;
  width: 100%;
  max-width: var(--container-max);
  contain: layout style;
}

.ad-container--top {
  margin-top: 0.75rem;
  margin-bottom: 1.25rem;
}

.ad-container--result {
  margin-top: 1.5rem;
  margin-bottom: 1.75rem;
}

.ad-container--bottom {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.ad-label {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.ad-slot {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-align: center;
}

.ad-slot--top {
  min-height: 100px;
}

.ad-slot--result {
  min-height: 250px;
}

.ad-slot--bottom {
  min-height: 250px;
}

.ad-slot__placeholder {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  user-select: none;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}

.breadcrumb a {
  color: var(--text-secondary);
}

.breadcrumb__sep {
  color: var(--border-strong);
}

/* Tool Hero */
.tool-hero {
  margin-bottom: 1.5rem;
}

.tool-hero__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.tool-hero__title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text);
}

.tool-hero__desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Calculator Panel */
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.calc-card__body {
  display: grid;
  grid-template-columns: 1fr;
}

.calc-inputs {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.calc-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.calc-section-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

.btn-reset {
  appearance: none;
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-reset:hover {
  background: var(--border);
  color: var(--text);
}

.btn-reset:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Form Controls */
.input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.125rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.field__label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.field__value-badge {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.field__control-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field__input,
.field__select {
  width: 100%;
  height: 46px;
  padding: 0 0.875rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field__input--with-unit {
  padding-right: 3.5rem;
}

.field__input:focus,
.field__select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}

.field__unit {
  position: absolute;
  right: 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.field__range {
  width: 100%;
  height: 6px;
  margin: 0.5rem 0 0.25rem;
  appearance: none;
  background: linear-gradient(
    to right,
    var(--primary) 0%,
    var(--primary) var(--progress, 50%),
    var(--border) var(--progress, 50%),
    var(--border) 100%
  );
  border-radius: 999px;
  cursor: pointer;
}

.field__range::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}

.field__range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}

.field__range:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.field__range-bounds {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

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

/* Results Area */
.calc-results {
  padding: 1.5rem;
  background: #f8fbff;
}

.result-primary {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.375rem;
  margin-bottom: 1rem;
}

.result-primary__label {
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0.92;
  margin: 0 0 0.35rem;
}

.result-primary__value {
  margin: 0;
  font-size: clamp(1.625rem, 4vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.result-primary__desc {
  margin: 0.45rem 0 0;
  font-size: 0.8125rem;
  opacity: 0.88;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
}

.result-item__label {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.result-item__value {
  margin: 0;
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.result-item__desc {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calc-status {
  margin: 0.875rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-height: 1.35em;
}

.calc-status--error {
  color: #b91c1c;
  font-weight: 600;
}

/* Content Sections (Guide, FAQ, Related Tools) */
.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.content-card__title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.guide-block + .guide-block {
  margin-top: 1.125rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--border);
}

.guide-block h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.guide-block p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.formula-box {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: var(--surface-muted);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* FAQ Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  padding: 1rem 1.125rem;
  font-weight: 600;
  font-size: 0.96875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-size: 1.25rem;
  line-height: 1;
  color: var(--primary);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item__answer {
  padding: 0 1.125rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin: 0;
}

/* Tool Directory Cards (Portal & Related Tools) */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

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

.tool-card__category {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.625rem;
}

.tool-card__title {
  margin: 0 0 0.45rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

.tool-card__desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex: 1 0 auto;
}

.tool-card__cta {
  margin-top: 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
}

/* Static Info / Policy Pages */
.prose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.prose-card h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.prose-card h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
}

.prose-card p,
.prose-card li {
  color: var(--text-secondary);
  font-size: 0.96875rem;
}

.prose-card ul {
  padding-left: 1.25rem;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer__links a {
  color: var(--text-secondary);
  font-weight: 500;
}

.site-footer__disclaimer {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.site-footer__copy {
  margin: 0;
  font-size: 0.8125rem;
}

/* Responsive Enhancements */
@media (min-width: 768px) {
  .container {
    padding: 0 1.5rem;
  }

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

  .calc-card__body {
    grid-template-columns: 1.05fr 0.95fr;
  }

  .calc-inputs {
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 1.75rem;
  }

  .calc-results {
    padding: 1.75rem;
  }

  .site-footer__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
