/* ═══════════════════════════════════════════════════════════════════
   cost.css — AI Cost Calculator styles
   Uses landing.css tokens (paper/ink/green design system)
   ═══════════════════════════════════════════════════════════════════ */

/* ——— Page layout ——— */
.cost-main {
  padding-top: 48px;
  padding-bottom: 80px;
  min-height: calc(100vh - 200px);
}

/* ——— Hero ——— */
.cost-hero {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 48px;
}

.cost-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--yellow-500);
  margin-bottom: 16px;
}

.cost-hero h1 {
  font-size: var(--h2-size);
  font-weight: var(--heading-weight);
  font-stretch: var(--display-stretch);
  letter-spacing: var(--h2-tracking);
  line-height: var(--h2-leading);
  margin-bottom: 20px;
}

.cost-lede {
  font-size: var(--body-l-size);
  line-height: var(--body-l-leading);
  color: var(--ink-2);
  max-width: 640px;
  margin: 0 auto;
}

/* ——— Two-column layout ——— */
.cost-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

@media (max-width: 960px) {
  .cost-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }
}

/* ——— Editor column ——— */
.cost-editor {
  min-width: 0;
  background: var(--paper-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  padding: 24px;
}

/* ——— Tabs ——— */
.cost-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-3);
  padding-bottom: 0;
}

.cost-tab {
  flex: 1;
  padding: 12px 16px;
  font-family: var(--font-core);
  font-size: 14px;
  font-weight: var(--subhead-weight);
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--dur-1) var(--ease-swift),
              border-color var(--dur-1) var(--ease-swift);
  margin-bottom: -1px;
}

.cost-tab:hover {
  color: var(--ink-1);
}

.cost-tab.active {
  color: var(--green-600);
  border-bottom-color: var(--green-600);
}

.cost-tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

/* ——— Panels ——— */
.cost-panel {
  animation: fadeIn 0.2s ease;
}

.cost-panel[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ——— Example Badge ——— */
.cost-example-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--yellow-700);
  background: var(--yellow-100);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  margin-bottom: 16px;
}

.cost-example-badge[hidden] {
  display: none;
}

/* ——— Visually Hidden ——— */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ——— Form elements ——— */
.cost-form-group {
  margin-bottom: 20px;
}

.cost-form-group:last-child {
  margin-bottom: 0;
}

.cost-label {
  display: block;
  font-size: 14px;
  font-weight: var(--subhead-weight);
  color: var(--ink-1);
  margin-bottom: 8px;
}

.cost-label-hint {
  font-weight: 400;
  color: var(--ink-4);
  font-size: 12px;
}

.cost-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  font-family: var(--font-core);
  font-size: var(--body-m-size);
  line-height: var(--body-m-leading);
  color: var(--ink-1);
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  resize: vertical;
}

.cost-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--green-100);
}

.cost-textarea::placeholder {
  color: var(--ink-4);
}

.cost-input {
  width: 100%;
  height: var(--control-h-md);
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-1);
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
}

.cost-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--green-100);
}

.cost-input::-webkit-outer-spin-button,
.cost-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cost-input[type="number"] {
  -moz-appearance: textfield;
}

.cost-field-note {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 4px;
}

/* ——— Field Errors ——— */
.cost-field-error {
  font-size: 11px;
  color: var(--red-600);
  margin-top: 4px;
}

.cost-field-error[hidden] {
  display: none;
}

.cost-input:invalid,
.cost-input.invalid {
  border-color: var(--red-500);
}

.cost-input:invalid:focus,
.cost-input.invalid:focus {
  box-shadow: 0 0 0 2px var(--red-100);
}

/* ——— Token inputs row ——— */
.cost-tokens-row {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.cost-tokens-row > .cost-form-group {
  margin-bottom: 0;
}

/* ——— Examples ——— */
.cost-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.cost-examples-label {
  font-size: 12px;
  color: var(--ink-4);
}

.cost-example-btn {
  padding: 4px 10px;
  background: var(--paper-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  font-family: var(--font-core);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-swift),
              background var(--dur-1) var(--ease-swift);
}

.cost-example-btn:hover {
  border-color: var(--accent);
  background: var(--green-100);
}

.cost-example-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* ——— Monthly runs ——— */
.cost-runs-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.cost-runs-input {
  width: 100%;
}

.cost-runs-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cost-preset-btn {
  padding: 4px 10px;
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-swift);
}

.cost-preset-btn:hover {
  border-color: var(--ink-3);
}

.cost-preset-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* ——— Workflow mode ——— */
.cost-workflow-intro {
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 20px;
  line-height: 1.5;
}

.cost-workflow-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.cost-step {
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  padding: 16px;
  position: relative;
}

.cost-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cost-step-number {
  width: 24px;
  height: 24px;
  background: var(--green-600);
  color: var(--text-on-accent);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cost-step-name-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  font-family: var(--font-core);
  font-size: 13px;
  font-weight: var(--subhead-weight);
  color: var(--ink-1);
  background: var(--paper-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
}

.cost-step-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.cost-step-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.cost-step-action-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: border-color var(--dur-1) var(--ease-swift),
              color var(--dur-1) var(--ease-swift);
}

.cost-step-action-btn:hover {
  border-color: var(--ink-3);
  color: var(--ink-1);
}

.cost-step-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cost-step-action-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.cost-step-prompt {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  font-family: var(--font-core);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-1);
  background: var(--paper-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
  resize: vertical;
  margin-bottom: 12px;
}

.cost-step-prompt:focus {
  outline: none;
  border-color: var(--accent);
}

.cost-step-prompt::placeholder {
  color: var(--ink-4);
}

.cost-step-tokens {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.cost-step-token-group {
  flex: 1;
}

.cost-step-token-label {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.cost-step-token-input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-1);
  background: var(--paper-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
}

.cost-step-token-input:focus {
  outline: none;
  border-color: var(--accent);
}

.cost-step-carry {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

.cost-step-carry input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--green-600);
}

.cost-step-carry-note {
  font-size: 11px;
  color: var(--ink-4);
  display: block;
  margin-left: 24px;
  margin-top: 2px;
}

.cost-add-step-btn {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-2);
  font-family: var(--font-core);
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-swift),
              color var(--dur-1) var(--ease-swift);
}

.cost-add-step-btn:hover {
  border-color: var(--accent);
  color: var(--green-600);
}

.cost-add-step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cost-add-step-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.cost-workflow-runs {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-3);
}

/* ——— Results column ——— */
.cost-results {
  min-width: 0;
  position: sticky;
  top: 24px;
}

.cost-results-header {
  margin-bottom: 20px;
}

.cost-results-title {
  font-size: var(--h6-size);
  font-weight: var(--subhead-weight);
  letter-spacing: var(--h6-tracking);
  margin-bottom: 4px;
}

.cost-results-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.cost-results-note {
  font-size: 12px;
  color: var(--ink-4);
  margin: 0;
}

.cost-results-note.snapshot {
  color: var(--yellow-500);
}

/* ——— UTC Time Display ——— */
.cost-results-time {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-4);
  background: var(--paper-1);
  padding: 2px 8px;
  border-radius: var(--r-1);
  margin: 0;
}

/* ——— Loading state ——— */
.cost-loading {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-3);
}

.cost-loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--line-2);
  border-top-color: var(--green-600);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ——— Error state ——— */
.cost-error {
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  padding: 24px;
  text-align: center;
  color: var(--ink-2);
}

.cost-error[hidden] {
  display: none;
}

.cost-error p {
  margin-bottom: 16px;
}

.cost-error .btn-secondary {
  background: var(--paper-0);
  color: var(--ink-1);
  border: 1px solid var(--line-2);
}

.cost-error .btn-secondary:hover {
  border-color: var(--ink-3);
  background: var(--paper-1);
}

/* ——— Results table ——— */
.cost-results-content[hidden] {
  display: none;
}

/* ——— Comparison Summary ——— */
.cost-comparison-summary {
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  color: var(--text-on-accent);
  border-radius: var(--r-3);
  padding: 24px;
  margin-bottom: 24px;
}

.cost-comparison-summary[hidden] {
  display: none;
}

.comparison-summary-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.comparison-baseline,
.comparison-alternative {
  text-align: center;
}

.comparison-label {
  display: block;
  font-size: 12px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.comparison-value {
  font-size: 24px;
  font-weight: var(--heading-weight);
  font-family: var(--font-mono);
}

.comparison-period {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.8;
}

.comparison-savings {
  color: var(--yellow-500);
}

.comparison-arrow {
  font-size: 24px;
  opacity: 0.6;
}

.comparison-result {
  background: rgba(255, 255, 255, 0.15);
  padding: 12px 20px;
  border-radius: var(--r-2);
  text-align: center;
}

.comparison-pct {
  display: block;
  font-size: 28px;
  font-weight: var(--heading-weight);
  font-family: var(--font-mono);
  color: var(--yellow-500);
}

.comparison-amount {
  display: block;
  font-size: 12px;
  opacity: 0.85;
}

.comparison-disclaimer {
  font-size: 11px;
  opacity: 0.7;
  text-align: center;
  margin-top: 16px;
  margin-bottom: 0;
}

.comparison-disclaimer a {
  color: inherit;
  text-decoration: underline;
}

/* ——— Table Wrapper ——— */
.cost-table-wrapper {
  overflow-x: auto;
  margin-bottom: 20px;
  min-width: 0;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 480px;
}

.cost-table th,
.cost-table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line-3);
}

.cost-table th {
  font-size: 11px;
  font-weight: var(--subhead-weight);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
}

.cost-table th:first-child,
.cost-table td:first-child {
  padding-left: 0;
}

.cost-table th:last-child,
.cost-table td:last-child {
  padding-right: 0;
}

.cost-col-num {
  text-align: right !important;
}

.cost-table td.cost-col-num {
  font-family: var(--font-mono);
  font-size: 13px;
}

.cost-model-name {
  font-weight: var(--subhead-weight);
  color: var(--ink-1);
}

.cost-model-name.baseline {
  color: var(--green-600);
}

.cost-model-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--r-1);
  margin-left: 6px;
  vertical-align: middle;
}

.cost-model-tag.baseline {
  background: var(--green-100);
  color: var(--green-700);
}

.cost-model-note {
  display: block;
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 400;
  margin-top: 2px;
}

.cost-unavailable {
  color: var(--ink-4);
  font-style: italic;
}

.cost-model-rate {
  display: block;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-4);
  margin-top: 2px;
}

.cost-monthly-note {
  font-size: 12px;
  color: var(--ink-4);
  margin-bottom: 12px;
}

.cost-savings {
  font-weight: var(--subhead-weight);
}

.cost-savings.positive {
  color: var(--green-600);
}

.cost-savings.negative {
  color: var(--red-600);
}

.cost-savings.neutral {
  color: var(--ink-3);
}

/* ——— Row highlight for baseline ——— */
.cost-table tr.baseline-row {
  background: var(--green-100);
}

.cost-table tr.baseline-row td {
  border-bottom-color: var(--green-600);
}

/* ——— Critical Note ——— */
.cost-critical-note {
  font-size: 13px;
  color: var(--ink-2);
  background: var(--yellow-100);
  border: 1px solid var(--yellow-300);
  border-radius: var(--r-2);
  padding: 12px 16px;
  margin-bottom: 20px;
}

.cost-critical-note strong {
  color: var(--yellow-700);
}

.cost-critical-note a {
  color: var(--green-700);
  font-weight: 500;
}

/* ——— Assumptions ——— */
.cost-assumptions {
  margin-bottom: 24px;
}

.cost-assumptions-details {
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
}

.cost-assumptions-details summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: var(--subhead-weight);
  color: var(--ink-2);
  cursor: pointer;
}

.cost-assumptions-details summary:hover {
  background: var(--paper-2);
}

.cost-assumptions-details summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.cost-assumptions-list {
  padding: 0 16px 16px;
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
  list-style-position: inside;
}

.cost-assumptions-list li {
  margin-bottom: 6px;
}

.cost-assumptions-list strong {
  color: var(--ink-2);
  font-weight: var(--subhead-weight);
}

.cost-assumptions-list a {
  color: var(--link);
}

.cost-assumptions-list a:hover {
  color: var(--link-hover);
}

/* ——— Step details ——— */
.cost-step-details {
  margin-bottom: 24px;
}

.cost-step-details[hidden] {
  display: none;
}

.cost-step-details-title {
  font-size: 14px;
  font-weight: var(--subhead-weight);
  margin-bottom: 12px;
}

#cost-step-breakdown {
  background: var(--paper-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  padding: 16px;
  font-size: 13px;
}

.cost-breakdown-model {
  margin-bottom: 16px;
}

.cost-breakdown-model:last-child {
  margin-bottom: 0;
}

.cost-breakdown-model-name {
  font-weight: var(--subhead-weight);
  color: var(--ink-1);
  margin-bottom: 8px;
}

.cost-breakdown-steps {
  display: grid;
  gap: 6px;
}

.cost-breakdown-step {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 1px dotted var(--line-3);
}

.cost-breakdown-step:last-child {
  border-bottom: none;
}

.cost-breakdown-step-name {
  color: var(--ink-3);
}

.cost-breakdown-step-cost {
  color: var(--ink-1);
}

.cost-breakdown-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-1);
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--line-2);
}

/* ——— CTA ——— */
.cost-cta {
  background: var(--green-700);
  color: var(--text-on-accent);
  border-radius: var(--r-3);
  padding: 28px;
  text-align: center;
}

.cost-cta-title {
  font-size: var(--h6-size);
  font-weight: var(--subhead-weight);
  margin-bottom: 8px;
}

.cost-cta-text {
  font-size: 14px;
  color: rgba(244, 242, 236, 0.8);
  margin-bottom: 20px;
}

.cost-cta .btn {
  background: var(--paper-1);
  color: var(--green-700);
  border-color: var(--paper-1);
}

.cost-cta .btn:hover {
  background: var(--paper-0);
}

.cost-cta-alt {
  font-size: 13px;
  color: rgba(244, 242, 236, 0.7);
  margin-top: 16px;
  margin-bottom: 0;
}

.cost-cta-alt a {
  color: var(--paper-1);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cost-cta-alt a:hover {
  color: var(--paper-0);
}

/* ——— Responsive ——— */
@media (max-width: 960px) {
  .cost-hero h1 {
    font-size: clamp(36px, 8vw, 56px);
  }

  .cost-results {
    position: static;
  }
}

@media (max-width: 640px) {
  .cost-main {
    padding-top: 32px;
  }

  .cost-hero {
    margin-bottom: 32px;
  }

  .cost-hero h1 {
    font-size: clamp(28px, 7vw, 44px);
  }

  .cost-lede {
    font-size: var(--body-m-size);
  }

  .cost-editor {
    padding: 16px;
  }

  .cost-table {
    font-size: 12px;
  }

  .cost-table th,
  .cost-table td {
    padding: 10px 6px;
  }

  .cost-table td.cost-col-num {
    font-size: 11px;
  }

  .cost-step-tokens {
    flex-direction: column;
    gap: 8px;
  }

  .comparison-summary-content {
    flex-direction: column;
    gap: 12px;
  }

  .comparison-arrow {
    transform: rotate(90deg);
  }

  .comparison-value {
    font-size: 20px;
  }

  .comparison-pct {
    font-size: 24px;
  }
}

/* ——— Reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  .cost-loading-spinner {
    animation: none;
  }

  .cost-panel {
    animation: none;
  }
}
