/* ==========================================================================
   Paddy Prompt Studio — Streaming royalty calculator
   Layers on /blog/style.css (same dark indigo/cyan palette and type scale).
   The card shell, .control, .seg, .tuner-hint and table.data rules are copied
   from the guitar tuner so the tools share one visual language.
   ========================================================================== */

:root {
  --good: #34d399;
  --near: #fcd34d;
  --off:  #fb7185;
}

/* ------------------------------------------------------------ Card shell */
.calc {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 22px;
  padding: 1.25rem; margin: 0.5rem 0 1rem;
  box-shadow: 0 30px 70px -40px rgba(99, 102, 241, 0.6);
}

.tuner-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border-soft);
}
.control {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.35rem 0.55rem;
}
.control > .lbl, .field > .lbl, .sub-lbl {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.62rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); font-weight: 700;
}
.control select, .calc input[type="number"], .calc input[type="text"] {
  font: inherit; font-size: 0.95rem; font-weight: 600; color: var(--text);
  background: #07080d; border: 1px solid var(--border); border-radius: 9px;
  padding: 0.45rem 0.55rem; min-height: 44px; box-sizing: border-box;
}
.control select { max-width: 15rem; }
.calc input[type="number"] { width: 100%; font-family: "JetBrains Mono", ui-monospace, monospace; }
.calc input:focus-visible, .calc select:focus-visible, .calc button:focus-visible {
  outline: 2px solid #67e8f9; outline-offset: 2px;
}
.control .fx-input { width: 6.5rem; }

/* ------------------------------------------------------------ Mode toggle */
.seg { display: inline-flex; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 12px; padding: 0.22rem; gap: 0.15rem; }
.seg button {
  font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer;
  border: 0; border-radius: 9px; padding: 0.4rem 0.7rem; min-height: 44px;
  background: transparent; color: var(--text-muted);
}
.seg button[aria-pressed="true"] { background: rgba(99, 102, 241, 0.22); color: #fff; }
.seg.mode { flex: 1 1 18rem; }
.seg.mode button { flex: 1 1 0; }

/* ------------------------------------------------------------ Layout */
.calc-grid { display: grid; gap: 1rem; padding-top: 1rem; }
@media (min-width: 820px) { .calc-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; } }

.inputs { display: grid; gap: 0.8rem; }
.field { display: grid; gap: 0.35rem; }
.field-row { display: flex; gap: 0.5rem; align-items: stretch; flex-wrap: wrap; }
.field-row > input { flex: 1 1 9rem; }
.field .note, .calc .note { font-size: 0.8rem; color: var(--text-dim); margin: 0; line-height: 1.45; }
.field select { width: 100%; max-width: none; }
.two-up { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }
.check {
  display: flex; align-items: center; gap: 0.6rem; cursor: pointer; min-height: 44px;
  font-size: 0.92rem; font-weight: 600;
}
.check input { width: 1.3rem; height: 1.3rem; accent-color: #818cf8; }
.box {
  border: 1px solid var(--border-soft); border-radius: 14px; padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02); display: grid; gap: 0.55rem;
}
[hidden] { display: none !important; }

.presets { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip-btn {
  font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; min-height: 44px;
  padding: 0.45rem 0.8rem; border-radius: 999px; color: #c7d2fe;
  background: rgba(129, 140, 248, 0.10); border: 1px solid rgba(129, 140, 248, 0.35);
}
.chip-btn:hover { background: rgba(129, 140, 248, 0.22); }

/* ------------------------------------------------------------ Result card */
.result {
  border: 1px solid rgba(129, 140, 248, 0.35); border-radius: 18px; padding: 1rem;
  background: radial-gradient(120% 90% at 0% 0%, rgba(99, 102, 241, 0.16), transparent 60%), #07080d;
  display: grid; gap: 0.6rem; transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.result .tag {
  justify-self: start; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.7rem;
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700;
  padding: 0.25rem 0.6rem; border-radius: 999px; color: #a5f3fc;
  background: rgba(34, 211, 238, 0.10); border: 1px solid rgba(34, 211, 238, 0.35);
}
.result .big {
  font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 800; color: #fff;
  font-size: clamp(2.2rem, 10vw, 3.3rem); line-height: 1.05; letter-spacing: -0.02em; margin: 0;
  overflow-wrap: anywhere;
}
.result .big.neg { color: var(--off); }
.result .sub { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.result .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.result .pair > div { border: 1px solid var(--border-soft); border-radius: 12px; padding: 0.55rem 0.7rem; }
.result .pair .v { display: block; font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; color: #a5f3fc; font-size: 1rem; overflow-wrap: anywhere; }
.result .coffee { margin: 0; font-weight: 600; color: #fde68a; }
.result.glow { border-color: rgba(52, 211, 153, 0.7); animation: glow 1.4s ease-out 1; }
@keyframes glow {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.0); }
  30% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.35), 0 0 40px rgba(34, 211, 238, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.0); }
}
@media (prefers-reduced-motion: reduce) {
  .result, .bar-fill { transition: none !important; }
  .result.glow { animation: none; box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.55); }
}

.warn-box {
  margin: 0; padding: 0.6rem 0.75rem; border-radius: 12px; font-size: 0.88rem; line-height: 1.45;
  color: #fde68a; background: rgba(252, 211, 77, 0.08); border: 1px solid rgba(252, 211, 77, 0.4);
}

/* ------------------------------------------------------------ CSS bar chart */
.bars { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: 6.6rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; font-size: 0.82rem; }
.bars .bn { color: var(--text-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 0.8rem; border-radius: 999px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #818cf8, #22d3ee); transition: width 0.35s ease; }
.bars li.blocked .bar-fill { background: repeating-linear-gradient(45deg, rgba(251,113,133,0.6) 0 6px, rgba(251,113,133,0.25) 6px 12px); width: 100% !important; opacity: 0.35; }
.bars .bv { font-family: "JetBrains Mono", ui-monospace, monospace; color: #a5f3fc; font-size: 0.78rem; text-align: right; min-width: 4.5rem; }
.bars li.blocked .bv { color: var(--off); }

/* ------------------------------------------------------------ Platform rows */
.platforms { margin-top: 1rem; border: 1px solid var(--border-soft); border-radius: 16px; padding: 0.4rem 0.8rem 0.8rem; }
.platforms > summary {
  cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 700; font-size: 0.95rem;
}
.plat-row {
  display: grid; gap: 0.35rem 0.7rem; padding: 0.6rem 0; border-top: 1px solid var(--border-soft);
  grid-template-columns: minmax(0, 1fr) auto;
}
.plat-row .pn { font-weight: 700; }
.plat-row .pct { font-family: "JetBrains Mono", ui-monospace, monospace; color: #a5f3fc; font-weight: 700; text-align: right; }
.plat-row .slider { grid-column: 1 / -1; }
.plat-row .rate { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-dim); }
.plat-row .rate input { width: 7.5rem; flex: 0 0 auto; }
@media (min-width: 640px) {
  .plat-row { grid-template-columns: 8rem minmax(0, 1fr) 3.4rem 15rem; align-items: center; }
  .plat-row .slider, .plat-row .rate { grid-column: auto; }
}
.calc input[type="range"] {
  width: 100%; height: 44px; margin: 0; background: transparent; accent-color: #818cf8; cursor: pointer;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }

/* ------------------------------------------------------------ Buttons */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer;
  min-height: 44px; padding: 0.6rem 1.15rem; border-radius: 12px; font: inherit; font-size: 0.95rem; font-weight: 700;
}
.btn-primary { border: 0; background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(129, 140, 248, 0.16); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.tuner-status { margin: 0.85rem 0 0; font-size: 0.88rem; color: var(--text-muted); min-height: 1.3em; }
.tuner-status.ok { color: #6ee7b7; font-weight: 600; }
.tuner-hint { margin: 0.9rem 0 0; text-align: center; font-size: 0.85rem; color: var(--text-dim); }
.tuner-hint kbd, .article-body kbd {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.78rem;
  background: rgba(129, 140, 248, 0.14); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 0.05em 0.35em; color: #c7d2fe;
}

/* ------------------------------------------------------------ Prose tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data caption { text-align: left; padding: 0.85rem 1rem 0.2rem; color: var(--text-dim); font-size: 0.82rem; }
table.data th, table.data td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border-soft); }
table.data thead th {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.68rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--indigo); font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.mono, table.data th.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.85rem; color: #a5f3fc; }
table.data tbody tr:hover { background: rgba(129, 140, 248, 0.05); }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 640px) {
  .calc { padding: 0.9rem; border-radius: 18px; }
  .tuner-controls { gap: 0.5rem; }
  .tuner-controls .control { flex: 1 1 100%; justify-content: space-between; }
  .control select { max-width: 12rem; }
  .actions > button { flex: 1 1 100%; }
  .bars li { grid-template-columns: 5.6rem minmax(0, 1fr) auto; }
}
