/* ==========================================================================
   The Tool Bakery — Retirement Savings Calculator (Modern Theme)
   --------------------------------------------------------------------------
   - Card-based UI, clean grids, accessible controls
   - Responsive + dark mode
   - Print-friendly for PDF/Print actions
   ========================================================================== */

/* Design tokens */
.ttb-tool {
  --bg: #ffffff;
  --ink: #0f172a;      /* slate-900 */
  --muted: #64748b;    /* slate-500 */
  --edge: #e2e8f0;     /* slate-200 */
  --soft: #f8fafc;     /* slate-50 */
  --brand: #111827;    /* near-black primary */
  --accent: #2563eb;   /* blue-600 (focus) */
  --danger: #ef4444;   /* red-500 */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(2,6,23,.04), 0 8px 24px rgba(2,6,23,.06);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .ttb-tool {
    --bg: #0b0f14;
    --ink: #e2e8f0;
    --muted: #94a3b8;
    --edge: #1f2937;
    --soft: #0f141a;
    --brand: #e2e8f0;
    --accent: #60a5fa;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.35);
  }
}

/* Container tweaks */
.ttb-tool.ttb-ret {
  background: transparent;
}

/* Header */
.ttb-header h2 {
  margin: 0 0 4px;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #000;
}

.ttb-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: .95rem;
}

/* Cards */
.ttb-card {
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.ttb-card.mini { padding: 12px; }

.ttb-card h3 {
  margin: 0 0 12px;
  font-size: 1.06rem;
  letter-spacing: -0.01em;
}

/* Grid system */
.ttb-grid { display: grid; gap: 12px; }
.ttb-grid.two   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ttb-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ttb-grid.four  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ttb-grid.seven { grid-template-columns: repeat(7, minmax(0, 1fr)); }

@media (max-width: 980px) {
  .ttb-grid.four  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ttb-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .ttb-grid.two,
  .ttb-grid.three,
  .ttb-grid.four,
  .ttb-grid.seven { grid-template-columns: 1fr; }
}

/* Labels & form controls */
label span {
  display: block;
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder { color: #94a3b8; }

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  background: #fff0;
}

/* Radio layout (timing) */
input[type="radio"] {
  accent-color: var(--accent);
}

/* Error state */
.error,
input.error,
select.error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent) !important;
}

/* Disabled (if used later) */
input:disabled,
select:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Actions */
.ttb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ttb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--soft);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
  transition: transform .04s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  user-select: none;
}

.ttb-btn:hover { box-shadow: var(--shadow); }
.ttb-btn:active { transform: translateY(1px); }

.ttb-btn.primary {
  background:linear-gradient(180deg,#10b981,#0ea5e9);
  color: #fff;
  border-color: var(--brand);
}

.ttb-btn.ghost { background:transparent; border:1px dashed #2b3643; color:var(--accent); }
.ttb-btn.outline { background: transparent; border-color: var(--edge); }

.ttb-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Results cards */
.ttb-results[hidden] { display: none !important; }
.ttb-results { margin-top: 20px; }

.ttb-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 980px) { .ttb-cards { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 680px) { .ttb-cards { grid-template-columns: 1fr; } }

.ttb-card .ttb-k {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.ttb-card .ttb-v {
  font-size: 1.14rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

/* Breakdown table */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}

thead th {
  font-size: .85rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--soft) 85%, transparent);
}

th, td {
  border-bottom: 1px solid var(--edge);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }

.t-right { text-align: right; }

/* Utility spacing */
.mt-12 { margin-top: 12px; }

/* Print styles (PDF/Print) */
@media print {
  .ttb-actions,
  .ttb-sub { display: none !important; }

  .ttb-card { break-inside: avoid; box-shadow: none; }

  body,
  .ttb-tool { background: #fff !important; color: #000 !important; }

  a[href]:after { content: ""; } /* no URL after links */
}

/* Focus-visible for accessibility */
.ttb-btn:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Small helper text in labels (used once) */
label small {
  font-size: .85em;
}
