/* ============================================================
   Calc — calculator-specific styles
   Depends on shared.css for theme tokens and base components
   ============================================================ */

/* Wider shell since the calculator has more content than a simple form */
.calc-shell.calc-shell--wide {
  max-width: 720px;
}

/* Each step block */
.step {
  margin-bottom: 22px;
}
.step:last-of-type { margin-bottom: 0; }

.step__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Option button row */
.step__options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

/* Buttons inside each step */
.step__option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  user-select: none;
  min-height: 44px;  /* iOS tap target */
}

.step__option:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.step__option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.step__option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

/* Syringe picker has 4 columns too (3 sizes + Other), but with tall cards */
.step__options--syringe {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.step__option--syringe {
  flex-direction: column;
  gap: 6px;
  padding: 12px 6px;
  min-height: 92px;
}

.step__option--syringe .syringe-svg {
  width: 100%;
  height: auto;
  flex-shrink: 0;
}

/* Default (unselected) syringe parts */
.step__option--syringe .syringe-svg .s-stroke {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s ease;
}
.step__option--syringe .syringe-svg .s-fill {
  fill: var(--bg-subtle);
  stroke: var(--text-muted);
  stroke-width: 1.4;
  stroke-linejoin: round;
  transition: fill 0.15s ease, stroke 0.15s ease;
}
.step__option--syringe .syringe-svg .s-solid {
  fill: var(--text-muted);
  stroke: none;
  transition: fill 0.15s ease;
}
.step__option--syringe .syringe-svg .s-tick {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-linecap: round;
  transition: stroke 0.15s ease;
}

/* Hover & selected — color shifts to accent */
.step__option--syringe:hover .syringe-svg .s-stroke,
.step__option--syringe:hover .syringe-svg .s-fill,
.step__option--syringe:hover .syringe-svg .s-tick,
.step__option--syringe.selected .syringe-svg .s-stroke,
.step__option--syringe.selected .syringe-svg .s-fill,
.step__option--syringe.selected .syringe-svg .s-tick {
  stroke: var(--accent);
}
.step__option--syringe:hover .syringe-svg .s-solid,
.step__option--syringe.selected .syringe-svg .s-solid {
  fill: var(--accent);
}
.step__option--syringe.selected .syringe-svg .s-fill {
  fill: var(--accent-soft);
}

.step__option--syringe .step__option-label {
  font-size: 0.85rem;
}

/* The "Other" option in syringe row stretches a generic icon */
.step__option--syringe.step__option--other {
  font-size: 0.9rem;
  justify-content: center;
}

/* Custom input that reveals when "Other" is clicked */
.step__custom {
  margin-top: 10px;
}

.step__custom.hidden {
  display: none;
}

.step__custom-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.step__custom-row input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  -moz-appearance: textfield;
}

.step__custom-row input[type="text"]:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}

.step__custom-row input[type="text"]::-webkit-outer-spin-button,
.step__custom-row input[type="text"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step__custom-row select {
  padding: 0 28px 0 12px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%235a6478' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
[data-theme="dark"] .step__custom-row select,
[data-theme="auto"] .step__custom-row select {
  /* Adjust arrow color for dark theme */
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .step__custom-row select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%239ba7b6' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
[data-theme="dark"] .step__custom-row select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%239ba7b6' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.step__custom-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* Dose unit toggle (mcg / mg) — sits inline with the options grid header */
.step__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.unit-toggle {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: 6px;
  padding: 2px;
  border: 1px solid var(--border);
}

.unit-toggle button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.unit-toggle button[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.unit-toggle button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Result panel ---------- */
.calc-result {
  margin-top: 28px;
  padding: 20px 22px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}

.calc-result__hint {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0;
}

.calc-result__hint .calc-result__big {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.calc-result__warning {
  display: none;
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Syringe fill graphic in the result — mimics looking down at a horizontal syringe */
.calc-result__viz {
  margin-top: 16px;
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.calc-result__viz-svg {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  height: auto;
}

.calc-result__viz-svg .v-barrel-outline {
  fill: var(--bg);
  stroke: var(--border-strong);
  stroke-width: 0.8;
  stroke-linejoin: round;
  transition: stroke 0.15s ease;
}
.calc-result__viz-svg .v-fill {
  fill: var(--accent);
  opacity: 0.85;
  transform-box: fill-box;
  transform-origin: right center;
  transition: transform 0.3s ease;
}
.calc-result__viz-svg .v-tip {
  fill: var(--bg);
  stroke: var(--border-strong);
  stroke-width: 0.8;
  stroke-linejoin: round;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.calc-result__viz-svg.has-fill .v-tip {
  fill: var(--accent);
  stroke: var(--accent);
  opacity: 0.85;
}
.calc-result__viz-svg .v-stroke {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 0.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.calc-result__viz-svg .v-solid {
  fill: var(--text-muted);
  stroke: none;
}
.calc-result__viz-svg .v-tick {
  stroke: var(--text-faint);
  stroke-width: 0.6;
  stroke-linecap: round;
}

.calc-result__viz-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  padding: 0 4px;
}

/* ---------- Share ---------- */
/* ---------- Converter card (below the main calculator) ---------- */
/* ---------- Responsive overrides for Calc ---------- */
@media (max-width: 600px) {
  .step__options {
    gap: 6px;
  }
  .step__option {
    font-size: 0.88rem;
    padding: 8px 4px;
  }
  .step__option--syringe {
    min-height: 80px;
    padding: 10px 4px;
  }
  .step__option--syringe .syringe-svg { height: auto; }
  .step__option--syringe .step__option-label { font-size: 0.78rem; }
  .calc-result__hint .calc-result__big { font-size: 1.15rem; }
  .converter-row input[type="number"] { font-size: 0.9rem; }
}

@media (max-width: 400px) {
  .step__option { font-size: 0.82rem; }
  .step__option--syringe .step__option-label { font-size: 0.72rem; }
}
