/* =====================================================
   DIRECT MAIL ROI CALCULATOR — Snowball Effect
   Navy Blue & Gold Theme | Wireframe-matched layout.
   To re-brand: update the :root variables only.
   ===================================================== */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Design Tokens ── */
:root {
  /* Brand — M3 Media Navy & Gold */
  --color-navy: #1d3257;
  /* Deep brand navy */
  --color-navy-mid: #25406c;
  --color-navy-light: #2d4d82;
  --color-gold: #c09340;
  /* Warm brand gold */
  --color-gold-light: #d6af66;
  --color-gold-glow: rgba(192, 147, 64, 0.20);

  /* Semantics */
  --color-negative: #c0392b;
  --color-negative-bg: rgba(192, 57, 43, 0.07);
  --color-negative-border: rgba(192, 57, 43, 0.28);
  --color-green: #1a7f4b;
  --color-green-bg: rgba(26, 127, 75, 0.10);
  --color-green-border: rgba(26, 127, 75, 0.35);
  --color-lift-bg: rgba(192, 147, 64, 0.08);
  --color-lift-border: rgba(192, 147, 64, 0.35);

  /* Surfaces */
  --color-bg: #f4f2ee;
  --color-surface: #ffffff;
  --color-surface-alt: #faf9f6;
  --color-border: rgba(13, 31, 60, 0.10);
  --color-text: #0d1f3c;
  --color-text-secondary: #4a5568;
  --color-placeholder: #a0aec0;
  --color-hint: #8898aa;

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --text-xs: 0.70rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.1rem;
  --text-4xl: 2.6rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radius / Shadow */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 4px rgba(13, 31, 60, 0.06), 0 2px 8px rgba(13, 31, 60, 0.04);
  --shadow-md: 0 4px 16px rgba(13, 31, 60, 0.10), 0 1px 4px rgba(13, 31, 60, 0.05);
  --shadow-lg: 0 8px 32px rgba(13, 31, 60, 0.14), 0 2px 8px rgba(13, 31, 60, 0.07);
  --shadow-gold: 0 0 0 3px rgba(201, 168, 76, 0.25);

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset / Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

/* ── Background: subtle crosshatch linen texture ── */
body {
  font-family: var(--font);
  background-color: var(--color-bg);
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 18px,
      rgba(13, 31, 60, 0.028) 18px, rgba(13, 31, 60, 0.028) 19px),
    repeating-linear-gradient(-45deg, transparent, transparent 18px,
      rgba(13, 31, 60, 0.028) 18px, rgba(13, 31, 60, 0.028) 19px);
  color: var(--color-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Dynamic negative-ROI color classes ── */
.text-red {
  color: var(--color-negative) !important;
}

.text-burgundy {
  color: #7b1e1e !important;
}

/* ── App Wrapper ── */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ══════════════════════════════════
   HEADER
   ══════════════════════════════════ */
.app-header {
  background: var(--color-navy);
  border-bottom: 2px solid var(--color-gold);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  box-shadow: 0 2px 20px rgba(13, 31, 60, 0.5);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.brand-logo {
  height: auto;
  max-height: 42px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.brand-tagline {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-gold-light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-style: italic;
  opacity: 0.95;
}

/* ══════════════════════════════════
   MAIN 2-COL LAYOUT (Left | Right outputs)
   ══════════════════════════════════ */
.calc-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: var(--space-6);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  align-items: start;
}

/* ══════════════════════════════════
   COLUMN MASTHEADS (YOUR BUSINESS / YOUR RESULTS)
   ══════════════════════════════════ */
.col-masthead {
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-5);
}

.col-masthead--left {
  background: var(--color-navy);
  border: 2px solid var(--color-gold);
  box-shadow: 0 3px 16px rgba(13, 31, 60, 0.25);
}

.col-masthead--right {
  background: linear-gradient(120deg, var(--color-navy) 0%, var(--color-navy-light) 100%);
  border: 2px solid var(--color-gold);
  box-shadow: 0 3px 16px rgba(13, 31, 60, 0.30);
  position: relative;
  overflow: hidden;
}

.col-masthead--right::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 38px,
      rgba(201, 168, 76, 0.07) 38px, rgba(201, 168, 76, 0.07) 39px);
  pointer-events: none;
}

.col-masthead-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-gold-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(201, 168, 76, 0.3);
  line-height: 1;
}

/* ══════════════════════════════════
   LEFT PANEL (YOUR BUSINESS)
   ══════════════════════════════════ */
.panel-inputs {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  transition: box-shadow var(--transition);
  overflow: hidden;
  /* clip grid children that overflow the card edge */
}

.panel-inputs:hover {
  box-shadow: var(--shadow-lg);
}

/* Sub-section label */
.input-section-header {
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: var(--space-2) 0 var(--space-1);
  border-bottom: 1px solid var(--color-gold-glow);
  margin-bottom: var(--space-3);
}

/* Input vertical stack */
.input-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Single input group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Input pairs — stacked vertically for clean fit in narrow left panel */
.inputs-pair {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.input-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
  word-break: break-word;
  /* allow long label text to wrap, not overflow */
  overflow-wrap: break-word;
}

.input-hint {
  font-size: var(--text-xs);
  color: var(--color-hint);
  font-style: italic;
  line-height: 1.3;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--color-surface-alt);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--color-gold);
  box-shadow: var(--shadow-gold);
}

/* Read-only wrapper */
.input-wrapper--readonly {
  background: rgba(13, 31, 60, 0.04);
  border-style: dashed;
  border-color: var(--color-gold-glow);
}

.input-wrapper--readonly:focus-within {
  box-shadow: none;
  border-color: var(--color-gold-glow);
}

.input-prefix {
  padding: 0 var(--space-2) 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-gold);
  user-select: none;
  line-height: 1;
}

.input-prefix--muted {
  color: var(--color-hint);
}

/* Suffix variant (for % sign) */
.input-prefix--suffix {
  padding: 0 var(--space-3) 0 var(--space-2);
}

.input-field {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--color-navy);
  padding: var(--space-3) var(--space-3) var(--space-3) 0;
  min-width: 0;
}

.input-field--no-prefix {
  padding-left: var(--space-3);
}

.input-field--readonly {
  color: var(--color-text-secondary);
  font-weight: 700;
  cursor: default;
  caret-color: transparent;
}

.input-field::placeholder {
  color: var(--color-placeholder);
  font-weight: 400;
}

/* "Auto" badge on calculated field */
.input-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-gold);
  background: var(--color-gold-glow);
  border-radius: 4px;
  padding: 2px 6px;
  margin-right: var(--space-2);
  white-space: nowrap;
}

/* Remove spinners */
.input-field::-webkit-inner-spin-button,
.input-field::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.input-field[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.disclaimer {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-placeholder);
  font-style: italic;
}

/* ══════════════════════════════════
   RIGHT OUTPUTS AREA
   ══════════════════════════════════ */
.outputs-area {
  display: flex;
  flex-direction: column;
}

/* ── Unified 2-col results grid ── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* Sub-column headers ("YOUR REVENUE" / "YOUR ROI") */
.results-col-header {
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--color-navy);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-gold);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.results-col-icon {
  font-size: var(--text-lg);
  line-height: 1;
}

/* ── Result Cards ── */
.result-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  border: 1.5px solid var(--color-border);
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  text-align: center;
  align-items: center;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Full-width: spans both columns — centered, not 100% wide */
.result-card--span {
  grid-column: 1 / -1;
  text-align: center;
  align-items: center;
  max-width: 65%;
  width: 65%;
  justify-self: center;
}


/* Soft warm-cream highlight card (value of 1 monthly customer) — NOT navy */
.result-card--highlight {
  background: linear-gradient(135deg, #fdf6e3 0%, #faf0d0 100%);
  border: 2px solid var(--color-gold);
  box-shadow: 0 2px 12px rgba(192, 147, 64, 0.20);
}

.result-card--highlight .result-label {
  color: var(--color-navy);
  opacity: 0.7;
}

.result-card--highlight .result-value {
  color: var(--color-navy);
}

/* Green full-width card (6-month customers) */
.result-card--green {
  background: var(--color-green-bg);
  border-color: var(--color-green-border);
}

.result-card--green .result-label {
  color: var(--color-green);
}

.result-card--green .result-value {
  color: var(--color-green);
}

/* Gold lift cards (2nd year) */
.result-card--lift {
  background: var(--color-lift-bg);
  border-color: var(--color-lift-border);
}

.result-card--lift .result-value {
  color: var(--color-navy);
}

/* Red risk cards */
.result-card--risk {
  background: var(--color-negative-bg);
  border-color: var(--color-negative-border);
}

.result-card--risk .result-label {
  color: var(--color-negative);
}

.result-card--risk .result-value {
  color: var(--color-negative);
}

/* Gold-highlighted breakeven card */
.result-card--breakeven {
  border: 2px solid var(--color-gold);
  box-shadow: 0 0 0 1px rgba(192, 147, 64, 0.20), var(--shadow-sm);
  font-weight: 700;
}

.result-card--breakeven .result-label {
  color: var(--color-gold);
}

.result-card--breakeven .result-value {
  color: var(--color-navy);
}

/* Text */
.result-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.4;
}

.result-sublabel {
  font-size: var(--text-xs);
  color: var(--color-hint);
  font-style: italic;
  line-height: 1.3;
}

.result-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-navy);
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.15s ease, color 0.25s ease;
}

.result-value--xl {
  font-size: var(--text-3xl);
}

/* Dash placeholder */
.result-value.is-empty {
  opacity: 0.22;
}

/* Flash on update */
@keyframes value-flash {
  0% {
    opacity: 0.35;
    transform: scale(0.97);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-value.updated {
  animation: value-flash 0.28s ease forwards;
}

/* Count-up animating state */
.result-value.counting {
  animation: none;
}

/* Dynamic sentence under Annual Value Created */
.result-dynamic-sentence {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-style: italic;
  line-height: 1.5;
  margin-top: var(--space-2);
  min-height: 1.5em;
  text-align: center;
}

/* ── Footnote ── */
.outputs-footnote {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid rgba(201, 168, 76, 0.28);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  line-height: 1.6;
}

.footnote-icon {
  color: var(--color-gold);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ══════════════════════════════════
   FOOTER
   ══════════════════════════════════ */
.app-footer {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-placeholder);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-top: var(--space-8);
}

/* ══════════════════════════════════
   RESPONSIVE — Tablet wide (1100px)
   ══════════════════════════════════ */
@media (max-width: 1100px) {
  .calc-layout {
    grid-template-columns: 300px 1fr;
    gap: var(--space-5);
    padding: var(--space-6) var(--space-5);
  }

  .result-value {
    font-size: var(--text-xl);
  }

  .result-value--xl {
    font-size: var(--text-2xl);
  }
}

/* ══════════════════════════════════
   RESPONSIVE — Tablet portrait (900px)
   Stack the two main columns vertically
   ══════════════════════════════════ */
@media (max-width: 900px) {
  .calc-layout {
    grid-template-columns: 1fr;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
  }

  .inputs-pair {
    grid-template-columns: 1fr 1fr;
  }

  /* still 2-col on tablet */
}

/* ══════════════════════════════════
   RESPONSIVE — Mobile (600px)
   ══════════════════════════════════ */
@media (max-width: 600px) {
  .header-inner {
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
  }

  .brand-tagline {
    font-size: var(--text-sm);
    letter-spacing: 0.1em;
  }

  .brand {
    justify-content: center;
  }


  .calc-layout {
    padding: var(--space-4) var(--space-3);
    gap: var(--space-4);
  }

  .panel-inputs {
    background: linear-gradient(160deg, #1a2e52 0%, #1d3257 100%);
    border: 1.5px solid var(--color-gold);
    padding: var(--space-5) var(--space-4);
  }

  /* Restyle inputs for dark panel */
  .panel-inputs .input-label {
    color: var(--color-gold-light);
  }

  .panel-inputs .input-section-header {
    color: var(--color-gold);
    border-bottom-color: rgba(201, 168, 76, 0.35);
  }

  .panel-inputs .disclaimer {
    color: rgba(255, 255, 255, 0.45);
  }

  .panel-inputs .input-wrapper {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(201, 168, 76, 0.4);
  }

  .panel-inputs .input-field {
    color: #ffffff;
  }

  .panel-inputs .input-field::placeholder {
    color: rgba(255, 255, 255, 0.3);
  }

  .panel-inputs .input-prefix {
    color: var(--color-gold-light);
  }

  .panel-inputs .input-wrapper--readonly {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(201, 168, 76, 0.25);
  }

  .panel-inputs .input-field--readonly {
    color: rgba(255, 255, 255, 0.6);
  }

  .panel-inputs .col-masthead--left {
    background: rgba(201, 168, 76, 0.15);
  }

  .panel-inputs .input-badge {
    background: rgba(201, 168, 76, 0.2);
  }

  .panel-inputs .input-hint {
    color: rgba(255, 255, 255, 0.40);
  }

  .inputs-pair {
    grid-template-columns: 1fr;
  }

  /* stack pairs vertically on mobile */

  /* ── Mobile output reorder: flex column + CSS order ──
     Revenue section first, then ROI section.
     Highlight card (Value of 1) shows at top, then Revenue, then ROI. */
  .results-grid {
    display: flex;
    flex-direction: column;
  }

  /* Span cards go full-width on mobile */
  .result-card--span {
    max-width: 100%;
    width: 100%;
  }

  /* Value of 1 Monthly Customer — at very top */
  .result-card--highlight {
    order: 1;
  }

  /* YOUR REVENUE header — second */
  .results-col-header--rev {
    order: 2;
  }

  /* Revenue cards — third group */
  .r-rev {
    order: 3;
  }

  /* 12-Month Customers — between Revenue & ROI */
  .result-card--green {
    order: 9;
  }

  /* YOUR ROI header */
  .results-col-header--roi {
    order: 10;
  }

  /* ROI cards */
  .r-roi {
    order: 11;
  }

  .result-value {
    font-size: var(--text-xl);
  }

  .result-value--xl {
    font-size: var(--text-2xl);
  }

  .col-masthead-title {
    font-size: var(--text-xl);
  }
}

/* ── Safe-area support for notched phones ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-footer {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }
}