/*
 * styles.css — "The Cost of Commuting"
 * Neutral, minimal, mobile-first. No external fonts or assets (self-contained).
 * Colors chosen for WCAG 2.1 AA contrast on white.
 */

:root {
  --bg: #f6f7f8;
  --card: #ffffff;
  --ink: #1a1d21;          /* body text on white: ~15:1 */
  --ink-soft: #4a4f57;     /* secondary text: ~8:1 */
  --line: #d7dbe0;
  --accent: #14532d;       /* deep green, ~9:1 on white */
  --accent-tint: #eef4f0;
  --focus: #1d4ed8;        /* focus ring */
  --radius: 10px;
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px) clamp(14px, 4vw, 28px) 48px;
}

/* ----------------------------- Header ----------------------------- */
.site-header h1 {
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  line-height: 1.2;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.disclaimer-lead {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
}

/* -------------------------- Pinned headline ----------------------- */
/* Sticks to the top of the viewport so the effective-salary figure stays
   visible while scrolling. Solid accent bar once populated; muted prompt
   before a salary is chosen. */
.pinned {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 0 20px;
  padding: 0.7rem clamp(0.9rem, 3vw, 1.2rem);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-wrap: nowrap; /* figure stays on the right; never wraps below the text */
  align-items: center;
  justify-content: space-between;
  gap: 0.15rem 1rem;
}
/* Left-hand text block: label with the hint on its own line beneath it. */
.pinned-text {
  display: flex;
  flex-direction: column;
  min-width: 0; /* lets the text wrap instead of pushing the figure out */
  flex: 1 1 auto;
}
.pinned-title {
  font-size: clamp(1.1rem, 3.4vw, 1.4rem);
  font-weight: 400;
  line-height: 1.2;
  color: #fff;
}
.pinned-label {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}
.pinned-hint {
  display: block; /* own line, under the label */
  font-size: 0.78rem;
  font-style: italic;
  color: rgba(255, 255, 255, 0.72);
}
.pinned-figure {
  font-size: clamp(1.35rem, 5vw, 1.9rem);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  flex: 0 0 auto; /* never shrink or wrap — always flush right */
  text-align: right;
  margin-left: auto;
}
/* Empty state: no salary yet — quiet, no big number. */
.pinned.is-empty {
  background: var(--card);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}
.pinned.is-empty .pinned-label {
  color: var(--ink-soft);
  font-style: italic;
}

/* ------------------------------ Cards ----------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 4vw, 24px);
  margin-bottom: 20px;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 1rem;
}

/* ------------------------------ Form ------------------------------ */
.field { margin-bottom: 1.1rem; }
.field:last-child { margin-bottom: 0; }

.field label,
.field .field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.98rem;
}

select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  padding: 0.6rem 0.7rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  appearance: none;
  /* simple inline chevron so we need no image asset */
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: right 1.05rem center, right 0.8rem center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}
select:hover { border-color: #b9bfc7; }

/* Commute time: two selects (hours + minutes) sized to content, side by side. */
.time-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.9rem;
  flex-wrap: wrap;
}
.time-part {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}
.time-picker select {
  width: auto;
  min-width: 4.6rem;
}
.time-suffix {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* Advanced options */
.advanced { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.advanced > summary,
.method > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.advanced > summary::before,
.method > summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 6px solid var(--ink-soft);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}
.advanced[open] > summary::before,
.method[open] > summary::before { transform: rotate(90deg); }
.advanced > summary::-webkit-details-marker,
.method > summary::-webkit-details-marker { display: none; }

.advanced-body { padding: 0.6rem 0 0.2rem; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}
.check:last-child { margin-bottom: 0; }
.check input[type="checkbox"] {
  width: 1.15rem; height: 1.15rem;
  margin: 0.15rem 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.check label { font-weight: 400; font-size: 0.97rem; }

/* ----------------------------- Result ----------------------------- */
.result-card { background: var(--accent-tint); border-color: #cfe0d6; }
.result p { margin: 0 0 0.7rem; }
.result p:last-child { margin-bottom: 0; }
.result-placeholder { color: var(--ink-soft); font-style: italic; }
/* Lines whose inputs aren't answered yet. */
.result .pending-line { color: var(--ink-soft); }
.result .pending { color: var(--ink-soft); font-weight: 700; }

.result .headline {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid #cfe0d6;
  font-size: 1.05rem;
}
.headline-label { display: block; color: var(--ink-soft); font-size: 0.95rem; }
.headline-figure {
  display: block;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
  margin-top: 0.1rem;
}

/* Inputs-used summary: hidden on screen, shown when printing. */
.inputs-summary { display: none; }
.inputs-summary h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.inputs-summary ul { margin: 0; padding-left: 1.2rem; }
.inputs-summary li { margin-bottom: 0.2rem; }

/* ----------------------------- Actions ---------------------------- */
.actions { margin-top: 1.3rem; }
button {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
}
button:hover { background: #0f3d22; }

/* --------------------------- Methodology -------------------------- */
.method-body { padding-top: 0.4rem; color: var(--ink); }
.method-body h3 { font-size: 1rem; margin: 1.1rem 0 0.3rem; }
.method-body p { margin: 0 0 0.6rem; }
.method-note { color: var(--ink-soft); font-size: 0.92rem; }

/* ------------------------------ Footer ---------------------------- */
.site-footer {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 8px;
  max-width: 62ch;
}

/* --------------------------- Accessibility ------------------------ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------- Wide screens ------------------------ */
@media (min-width: 780px) {
  /* Two-up the first four selects on desktop; keep it comfortable. */
  #commute-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.2rem;
  }
  #commute-form .field:nth-child(5) { grid-column: 1 / -1; } /* distance full width */
  #commute-form .check-field { grid-column: 1 / -1; } /* parking row full width */
  #commute-form .advanced { grid-column: 1 / -1; }
}

/* ------------------------------ Print ----------------------------- */
@media print {
  :root { --bg: #fff; }
  body { font-size: 12pt; }
  .no-print,
  #commute-form,
  .pinned,
  .site-header .disclaimer-lead,
  .method { display: none !important; }
  .card { border: none; padding: 0; margin: 0 0 16pt; background: #fff; }
  .result-card { background: #fff; }
  .inputs-summary { display: block; margin-top: 12pt; }
  .result .headline { border-top: 1px solid #999; }
  .headline-figure { color: #000; }
  .wrap { max-width: none; padding: 0; }
  a[href]::after { content: ""; } /* no URL expansion clutter */
}
