/**
 * Yoga Studio Revenue & Capacity Calculator
 * Scoped to .yoga-revenue-calculator-container
 */

.yoga-revenue-calculator-container,
.yoga-revenue-calculator-container *,
.yoga-revenue-calculator-container *::before,
.yoga-revenue-calculator-container *::after {
  box-sizing: border-box;
}

.yoga-revenue-calculator-container {
  --yrc-primary: var(--btn-primary, #1dbb99);
  --yrc-primary-hover: var(--btn-primary-hover, #17a885);
  --yrc-text: #0f172a;
  --yrc-body: #334155;
  --yrc-muted: #64748b;
  --yrc-border: #e2e8f0;
  --yrc-bg: #ffffff;
  --yrc-tint: #f0fdfa;
  --yrc-negative: #b91c1c;
  --yrc-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);

  max-width: 100%;
  font-family: Ubuntu, Roboto, "Noto Sans", system-ui, sans-serif;
  color: var(--yrc-text);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.yrc-panel {
  background: var(--yrc-bg);
  border: 1px solid var(--yrc-border);
  border-radius: 16px;
  box-shadow: var(--yrc-shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.yrc-panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--yrc-text);
}

.yrc-panel-lead {
  margin: 0 0 1.25rem;
  color: var(--yrc-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.yrc-fields {
  display: grid;
  gap: 1.5rem;
}

/* Nested grids, not display:contents - Safari drops contents children from the parent grid. */
.yrc-field-group {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

@media (min-width: 640px) {
  .yrc-field-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .yrc-field--wide {
    grid-column: 1 / -1;
  }
}

.yrc-field {
  min-width: 0;
}

.yrc-field label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--yrc-text);
}

.yrc-field-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

/* Native range + accent-color: Android Chrome breaks on appearance:none thumbs. */
.yrc-field-controls input[type="range"] {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0;
  background: transparent;
  accent-color: var(--yrc-primary);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: auto;
  appearance: auto;
  -webkit-tap-highlight-color: rgba(29, 187, 153, 0.2);
}

.yrc-field-controls input[type="number"] {
  width: 6.5rem;
  min-width: 6.5rem;
  max-width: 42%;
  min-height: 48px;
  padding: 0.55rem 0.5rem;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  border: 1px solid var(--yrc-border);
  border-radius: 8px;
  background: #fff;
  color: var(--yrc-text);
  -webkit-appearance: none;
  appearance: none;
  -moz-appearance: textfield;
  box-shadow: none;
  background-clip: padding-box;
  touch-action: manipulation;
}

.yrc-field-controls input[type="number"]::-webkit-outer-spin-button,
.yrc-field-controls input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.yrc-field-controls input[type="number"]:focus {
  outline: none;
  border-color: var(--yrc-primary);
  box-shadow: 0 0 0 3px rgba(29, 187, 153, 0.22);
}

/* Theme marks empty/out-of-range inputs red - keep calculator fields calm on Android. */
.yrc-field-controls input:invalid {
  border-color: var(--yrc-border);
}

.yrc-field-controls input[type="range"]:focus-visible {
  outline: 2px solid var(--yrc-primary);
  outline-offset: 2px;
}

.yrc-hero-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.yrc-hero-card {
  min-width: 0;
  background: var(--yrc-tint);
  border: 1px solid rgba(29, 187, 153, 0.2);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  text-align: center;
}

.yrc-hero-card--negative {
  background: #fef2f2;
  border-color: #fecaca;
}

.yrc-hero-card-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--yrc-muted);
  text-transform: none;
}

.yrc-hero-card-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--yrc-text);
  overflow-wrap: break-word;
}

.yrc-hero-card--negative .yrc-hero-card-value {
  color: var(--yrc-negative);
}

@media (min-width: 768px) {
  .yrc-hero-card-value {
    font-size: 1.65rem;
  }
}

.yrc-secondary-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 768px) {
  .yrc-secondary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.yrc-secondary-item {
  min-width: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--yrc-border);
  border-radius: 10px;
  background: #fafafa;
}

.yrc-secondary-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--yrc-muted);
}

.yrc-secondary-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--yrc-text);
  overflow-wrap: break-word;
}

.yrc-interpret {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--yrc-body);
  line-height: 1.6;
}

.yrc-interpret li + li {
  margin-top: 0.5rem;
}

.yrc-insight {
  background: linear-gradient(135deg, #0c3d38 0%, #1a7a69 100%);
  color: #fff;
  border-radius: 16px;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
}

.yrc-insight p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

.yrc-insight p + p {
  margin-top: 0.85rem;
}

.yrc-insight strong {
  color: #fff;
  font-weight: 600;
}

.yrc-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.yrc-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.92rem;
}

.yrc-table th,
.yrc-table td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--yrc-border);
}

.yrc-table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--yrc-muted);
  background: #fafafa;
}

.yrc-table td:last-child,
.yrc-table th:last-child {
  text-align: right;
}

.yrc-scenario-row--current {
  background: var(--yrc-tint);
  font-weight: 600;
}

.yrc-disclaimer {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--yrc-muted);
  line-height: 1.5;
}

/* Compact native sliders on Mac Safari / Chrome. */
@media (hover: hover) and (pointer: fine) {
  .yrc-field-controls input[type="range"] {
    height: 28px;
    min-height: 28px;
  }

  .yrc-field-controls input[type="number"] {
    min-height: 40px;
  }
}

/* Android Chrome sometimes also matches hover:hover. Coarse pointers stay 48px. */
@media (pointer: coarse) {
  .yrc-field-controls input[type="range"] {
    height: 48px;
    min-height: 48px;
  }

  .yrc-field-controls input[type="number"] {
    min-height: 48px;
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  .cb-page:has(.yoga-revenue-calculator-container) .cb-wrap {
    padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
  }

  .cb-page:has(.yoga-revenue-calculator-container) .cb-hero {
    padding: 2rem 0 1.15rem;
  }

  .cb-page:has(.yoga-revenue-calculator-container)
    .cb-section--tint:has(.yoga-revenue-calculator-container) {
    padding-top: 1.25rem;
    padding-bottom: 2.25rem;
  }

  .yrc-panel {
    padding: 1.1rem;
    margin-bottom: 1.15rem;
    border-radius: 12px;
  }

  .yrc-panel-title {
    font-size: 1.15rem;
  }

  .yrc-hero-card {
    padding: 0.85rem 0.75rem;
    text-align: left;
  }

  .yrc-hero-card-label {
    font-size: 0.72rem;
  }

  .yrc-hero-card-value {
    font-size: 1.1rem;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .yrc-secondary-item {
    padding: 0.65rem 0.7rem;
  }

  .yrc-insight {
    padding: 1.1rem 1.15rem;
    margin-bottom: 1.15rem;
    border-radius: 12px;
  }

  .yrc-insight p {
    font-size: 0.95rem;
  }

  .yrc-hero-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .yrc-cover {
    flex-direction: column;
    padding: 0.9rem 0.95rem;
  }

  .yrc-cover-detail {
    max-width: none;
  }

  .yrc-field-controls {
    gap: 0.55rem;
  }

  .yrc-field-controls input[type="number"] {
    width: 5.75rem;
    min-width: 5.75rem;
    max-width: 36%;
  }

  .yrc-table-wrap {
    overflow: visible;
  }

  .yrc-table,
  .yrc-table tbody,
  .yrc-table tr,
  .yrc-table td {
    display: block;
    width: 100%;
  }

  .yrc-table thead {
    display: none;
  }

  .yrc-table tr {
    margin-bottom: 0.65rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--yrc-border);
    border-radius: 10px;
    background: #fff;
  }

  .yrc-table tr:last-child {
    margin-bottom: 0;
  }

  .yrc-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.32rem 0;
    border-bottom: none;
    text-align: right;
  }

  .yrc-table td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--yrc-muted);
    text-align: left;
  }
}

@media (max-width: 400px) {
  .yrc-hero-grid,
  .yrc-secondary-grid,
  .yrc-year-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .yrc-hero-card {
    text-align: left;
  }

  .yrc-field-controls input[type="number"] {
    width: 5.25rem;
    min-width: 5.25rem;
  }
}

.yrc-field-group-title {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--yrc-muted);
}

.yrc-field-group + .yrc-field-group .yrc-field-group-title {
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--yrc-border);
}

.yrc-field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--yrc-muted);
  line-height: 1.4;
}

.yrc-cover {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(29, 187, 153, 0.25);
  background: var(--yrc-tint);
  margin-bottom: 1rem;
}

.yrc-cover--short {
  background: #fef2f2;
  border-color: #fecaca;
}

.yrc-cover-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--yrc-muted);
  margin-bottom: 0.25rem;
}

.yrc-cover-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--yrc-text);
}

.yrc-cover--short .yrc-cover-value {
  color: var(--yrc-negative);
}

.yrc-cover-detail {
  margin: 0;
  font-size: 0.9rem;
  color: var(--yrc-body);
  line-height: 1.5;
  max-width: 36rem;
}

.yrc-year-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .yrc-year-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .yrc-year-grid--opening {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.yrc-derived {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--yrc-body);
}

.yrc-note {
  margin: 0.25rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: var(--yrc-body);
  font-size: 0.88rem;
  line-height: 1.5;
}

.yrc-note[hidden] {
  display: none;
}
