/* ═══════════════════════════════════════════════════════════════
   Number Base Converter - Tool Stylesheet
   File: number-base-converter.css

   Fonts are loaded via <link> in the HTML head (not @import here)
   to avoid an extra render-blocking request chain.
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
  --nbc-accent:        #D4A373;
  --nbc-accent-dim:    rgba(212, 163, 115, 0.15);
  --nbc-accent-glow:   rgba(212, 163, 115, 0.35);
  --nbc-success:       #4e9e57;
  --nbc-success-bg:    rgba(78, 158, 87, 0.12);
  --nbc-error:         #d95555;
  --nbc-mono:          'JetBrains Mono', 'Consolas', monospace;
  --nbc-display:       'Syne', sans-serif;
  --nbc-radius:        12px;
  --nbc-radius-sm:     8px;
  --nbc-radius-lg:     18px;
  --nbc-transition:    0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --nbc-surface:       #ffffff;
  --nbc-surface-2:     #f5f1d8;
  --nbc-border:        rgba(0, 0, 0, 0.09);
  --nbc-border-focus:  var(--nbc-accent);
  --nbc-text:          #1a1510;
  --nbc-text-muted:    #6b6252;
  --nbc-input-bg:      #ffffff;
  --nbc-badge-bg:      rgba(212, 163, 115, 0.12);
  --nbc-badge-text:    #9a6c3a;
  --nbc-shadow:        0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --nbc-shadow-hover:  0 6px 24px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --nbc-shadow-focus:  0 0 0 3px var(--nbc-accent-glow);
}

[data-theme="dark"] {
  --nbc-surface:       #242018;
  --nbc-surface-2:     #2e2820;
  --nbc-border:        rgba(255, 255, 255, 0.08);
  --nbc-border-focus:  var(--nbc-accent);
  --nbc-text:          #f0ead8;
  --nbc-text-muted:    #9a8e7a;
  --nbc-input-bg:      #1e1a14;
  --nbc-badge-bg:      rgba(212, 163, 115, 0.14);
  --nbc-badge-text:    #d4a373;
  --nbc-shadow:        0 2px 12px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.20);
  --nbc-shadow-hover:  0 6px 28px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.30);
  --nbc-shadow-focus:  0 0 0 3px rgba(212,163,115,0.20);
  --nbc-accent:        #D4A373;
  --nbc-accent-dim:    rgba(212, 163, 115, 0.20);
  --nbc-accent-glow:   rgba(212, 163, 115, 0.40);
  --nbc-error:         #e87070;
  --nbc-success:       #6cb87a;
  --nbc-success-bg:    rgba(108, 184, 122, 0.15);
}

/* ── Wrapper ────────────────────────────────────────────────────── */
.nbc-wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 8px 0 56px;
}

/* ── Source-base Selector ───────────────────────────────────────── */
.nbc-source-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.nbc-source-selector .nbc-label-small {
  font-family: var(--nbc-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nbc-text-muted);
  white-space: nowrap;
  margin-right: 2px;
}
.nbc-base-btn {
  font-family: var(--nbc-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--nbc-border);
  background: var(--nbc-surface);
  color: var(--nbc-text-muted);
  cursor: pointer;
  transition: var(--nbc-transition);
  outline: none;
}
.nbc-base-btn:hover {
  border-color: var(--nbc-accent);
  color: var(--nbc-accent);
  background: var(--nbc-accent-dim);
}
.nbc-base-btn.active {
  border-color: var(--nbc-accent);
  background: var(--nbc-accent);
  color: #fff;
  box-shadow: 0 2px 10px var(--nbc-accent-glow);
}
/* Keyboard focus-visible - replaces outline:none without losing accessibility */
.nbc-base-btn:focus-visible {
  outline: 2px solid var(--nbc-accent);
  outline-offset: 2px;
}

/* ── Main Input Card ────────────────────────────────────────────── */
.nbc-input-card {
  background: var(--nbc-surface);
  border: 1.5px solid var(--nbc-border);
  border-radius: var(--nbc-radius-lg);
  box-shadow: var(--nbc-shadow);
  overflow: hidden;
  transition: border-color var(--nbc-transition), box-shadow var(--nbc-transition);
}
.nbc-input-card:focus-within {
  border-color: var(--nbc-border-focus);
  box-shadow: var(--nbc-shadow-focus);
}

.nbc-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--nbc-border);
  gap: 10px;
  flex-wrap: wrap;
}
.nbc-input-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nbc-base-badge {
  font-family: var(--nbc-display);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--nbc-badge-bg);
  color: var(--nbc-badge-text);
  transition: background var(--nbc-transition), color var(--nbc-transition);
}
.nbc-base-name {
  font-family: var(--nbc-mono);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--nbc-text-muted);
}
.nbc-input-actions {
  display: flex;
  gap: 6px;
}
.nbc-icon-btn {
  background: none;
  border: 1.5px solid var(--nbc-border);
  border-radius: var(--nbc-radius-sm);
  color: var(--nbc-text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--nbc-transition);
  outline: none;
  flex-shrink: 0;
}
.nbc-icon-btn:hover {
  border-color: var(--nbc-accent);
  color: var(--nbc-accent);
  background: var(--nbc-accent-dim);
}
.nbc-icon-btn:focus-visible {
  outline: 2px solid var(--nbc-accent);
  outline-offset: 2px;
}
.nbc-icon-btn svg { pointer-events: none; }

.nbc-main-input {
  width: 100%;
  box-sizing: border-box;
  padding: 18px 20px;
  border: none;
  background: transparent;
  font-family: var(--nbc-mono);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--nbc-text);
  caret-color: var(--nbc-accent);
  outline: none;
  letter-spacing: 0.04em;
  line-height: 1.5;
}
.nbc-main-input::placeholder {
  color: var(--nbc-text-muted);
  opacity: 0.4;
}
/* Remove number input spinners */
.nbc-main-input::-webkit-outer-spin-button,
.nbc-main-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.nbc-input-footer {
  padding: 8px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 34px;
}
.nbc-validation-msg {
  font-family: var(--nbc-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--nbc-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color var(--nbc-transition);
}
.nbc-validation-msg.error  { color: var(--nbc-error); }
.nbc-validation-msg.ok     { color: var(--nbc-success); }
.nbc-char-count {
  font-family: var(--nbc-mono);
  font-size: 0.67rem;
  color: var(--nbc-text-muted);
  opacity: 0.65;
}

/* ── Output Grid ────────────────────────────────────────────────── */
.nbc-output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.nbc-output-card {
  background: var(--nbc-surface);
  border: 1.5px solid var(--nbc-border);
  border-radius: var(--nbc-radius-lg);
  box-shadow: var(--nbc-shadow);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--nbc-transition), border-color var(--nbc-transition), transform var(--nbc-transition);
  animation: nbc-pop-in 0.28s ease both;
}
.nbc-output-card:nth-child(1) { animation-delay:   0ms; }
.nbc-output-card:nth-child(2) { animation-delay:  45ms; }
.nbc-output-card:nth-child(3) { animation-delay:  90ms; }
.nbc-output-card:nth-child(4) { animation-delay: 135ms; }

.nbc-output-card:hover {
  box-shadow: var(--nbc-shadow-hover);
  transform: translateY(-2px);
}
.nbc-output-card.is-source {
  border-color: var(--nbc-accent);
  background: var(--nbc-accent-dim);
}
.nbc-output-card.is-source::after {
  content: 'INPUT';
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--nbc-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--nbc-accent);
  opacity: 0.65;
}

.nbc-output-card-header {
  display: flex;
  align-items: center;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--nbc-border);
}
.nbc-output-base-label {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.nbc-output-base-num {
  font-family: var(--nbc-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--nbc-accent);
  line-height: 1;
}
.nbc-output-base-word {
  font-family: var(--nbc-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nbc-text-muted);
}

.nbc-output-value {
  padding: 14px;
  flex: 1;
  min-height: 54px;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.nbc-output-value code {
  font-family: var(--nbc-mono);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--nbc-text);
  letter-spacing: 0.03em;
  line-height: 1.65;
  word-break: break-all;
  background: none;
  padding: 0;
}
.nbc-output-value .nbc-placeholder {
  font-family: var(--nbc-mono);
  font-size: 0.85rem;
  color: var(--nbc-text-muted);
  opacity: 0.35;
}

.nbc-output-card-footer {
  padding: 8px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nbc-digit-count {
  font-family: var(--nbc-mono);
  font-size: 0.63rem;
  color: var(--nbc-text-muted);
  opacity: 0.6;
}
.nbc-copy-btn {
  font-family: var(--nbc-mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--nbc-border);
  background: none;
  color: var(--nbc-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--nbc-transition);
  outline: none;
  flex-shrink: 0;
  white-space: nowrap;
}
.nbc-copy-btn:hover {
  border-color: var(--nbc-accent);
  color: var(--nbc-accent);
  background: var(--nbc-accent-dim);
}
.nbc-copy-btn.copied {
  border-color: var(--nbc-success);
  color: var(--nbc-success);
  background: var(--nbc-success-bg);
}
.nbc-copy-btn:focus-visible {
  outline: 2px solid var(--nbc-accent);
  outline-offset: 2px;
}

/* ── Section Card (shared base) ─────────────────────────────────── */
.nbc-section-card {
  background: var(--nbc-surface);
  border: 1.5px solid var(--nbc-border);
  border-radius: var(--nbc-radius-lg);
  padding: 20px 22px;
  box-shadow: var(--nbc-shadow);
}

.nbc-section-title {
  font-family: var(--nbc-display);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--nbc-text-muted);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.nbc-section-title::before {
  content: '';
  display: block;
  width: 18px;
  height: 2px;
  background: var(--nbc-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Bit Visualiser ─────────────────────────────────────────────── */
.nbc-bit-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; /* room for scrollbar */
}
.nbc-bit-scroll::-webkit-scrollbar { height: 4px; }
.nbc-bit-scroll::-webkit-scrollbar-track { background: transparent; }
.nbc-bit-scroll::-webkit-scrollbar-thumb { background: var(--nbc-border); border-radius: 4px; }

.nbc-bit-wrap {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  min-width: max-content;
  padding: 4px 0;
}
.nbc-bit-group {
  display: flex;
  gap: 4px;
}
.nbc-bit-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.nbc-bit-box {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1.5px solid var(--nbc-border);
  background: var(--nbc-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--nbc-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--nbc-text-muted);
  transition: background var(--nbc-transition), color var(--nbc-transition),
              border-color var(--nbc-transition), box-shadow var(--nbc-transition);
  user-select: none;
}
.nbc-bit-box.on {
  background: var(--nbc-accent);
  border-color: var(--nbc-accent);
  color: #fff;
  box-shadow: 0 0 8px var(--nbc-accent-glow);
}
.nbc-bit-pos {
  font-family: var(--nbc-mono);
  font-size: 0.48rem;
  color: var(--nbc-text-muted);
  opacity: 0.5;
  user-select: none;
}
.nbc-bit-separator {
  width: 1px;
  height: 30px;
  background: var(--nbc-border);
  margin: 0 2px;
  align-self: flex-start;
  flex-shrink: 0;
}
.nbc-bit-empty {
  font-family: var(--nbc-mono);
  font-size: 0.78rem;
  color: var(--nbc-text-muted);
  opacity: 0.4;
}
.nbc-bit-overflow-note {
  font-family: var(--nbc-mono);
  font-size: 0.68rem;
  color: var(--nbc-text-muted);
  opacity: 0.6;
  margin-top: 8px;
  display: block;
}

/* ── Info Panel ─────────────────────────────────────────────────── */
.nbc-info-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.nbc-info-chip {
  background: var(--nbc-surface);
  border: 1.5px solid var(--nbc-border);
  border-radius: var(--nbc-radius);
  padding: 14px 16px;
  box-shadow: var(--nbc-shadow);
}
.nbc-info-chip-label {
  font-family: var(--nbc-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nbc-text-muted);
  margin-bottom: 6px;
}
.nbc-info-chip-value {
  font-family: var(--nbc-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--nbc-text);
  word-break: break-all;
}
.nbc-info-chip-value.accent { color: var(--nbc-accent); }

/* ── Custom Base ────────────────────────────────────────────────── */
.nbc-custom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.nbc-custom-base-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.nbc-custom-base-input-wrap label {
  font-family: var(--nbc-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--nbc-text-muted);
  white-space: nowrap;
}
.nbc-number-input {
  width: 68px;
  padding: 7px 10px;
  border-radius: var(--nbc-radius-sm);
  border: 1.5px solid var(--nbc-border);
  background: var(--nbc-input-bg);
  color: var(--nbc-text);
  font-family: var(--nbc-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: var(--nbc-transition);
  /* Remove spinners */
  -moz-appearance: textfield;
}
.nbc-number-input::-webkit-outer-spin-button,
.nbc-number-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.nbc-number-input:focus {
  border-color: var(--nbc-accent);
  box-shadow: var(--nbc-shadow-focus);
}
.nbc-number-input:focus-visible {
  outline: 2px solid var(--nbc-accent);
  outline-offset: 2px;
}

.nbc-custom-output-box {
  flex: 1;
  min-width: 160px;
  padding: 9px 14px;
  border-radius: var(--nbc-radius-sm);
  border: 1.5px solid var(--nbc-border);
  background: var(--nbc-surface-2);
  font-family: var(--nbc-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--nbc-text);
  letter-spacing: 0.03em;
  min-height: 40px;
  word-break: break-all;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
}
.nbc-custom-output-box .nbc-placeholder {
  color: var(--nbc-text-muted);
  opacity: 0.35;
  font-weight: 400;
}

/* ── History ────────────────────────────────────────────────────── */
.nbc-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.nbc-history-header .nbc-section-title { margin: 0; }
.nbc-history-clear-btn {
  font-family: var(--nbc-mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1.5px solid var(--nbc-border);
  background: none;
  color: var(--nbc-text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--nbc-transition);
  outline: none;
  flex-shrink: 0;
}
.nbc-history-clear-btn:hover {
  border-color: var(--nbc-error);
  color: var(--nbc-error);
}
.nbc-history-clear-btn:focus-visible {
  outline: 2px solid var(--nbc-error);
  outline-offset: 2px;
}

.nbc-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.nbc-history-list::-webkit-scrollbar { width: 4px; }
.nbc-history-list::-webkit-scrollbar-track { background: transparent; }
.nbc-history-list::-webkit-scrollbar-thumb { background: var(--nbc-border); border-radius: 4px; }

.nbc-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--nbc-radius-sm);
  border: 1.5px solid var(--nbc-border);
  background: var(--nbc-surface-2);
  cursor: pointer;
  transition: var(--nbc-transition);
  user-select: none;
}
.nbc-history-item:hover {
  border-color: var(--nbc-accent);
  background: var(--nbc-accent-dim);
}
.nbc-history-item:focus-visible {
  outline: 2px solid var(--nbc-accent);
  outline-offset: 2px;
}
.nbc-history-from {
  font-family: var(--nbc-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--nbc-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nbc-history-meta {
  font-family: var(--nbc-mono);
  font-size: 0.63rem;
  font-weight: 600;
  color: var(--nbc-text-muted);
  white-space: nowrap;
}
.nbc-history-empty {
  font-family: var(--nbc-mono);
  font-size: 0.78rem;
  color: var(--nbc-text-muted);
  opacity: 0.4;
  text-align: center;
  padding: 16px 0;
}

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes nbc-pop-in {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}
@keyframes nbc-value-flash {
  from { opacity: 0.25; }
  to   { opacity: 1; }
}
.nbc-value-updated code { animation: nbc-value-flash 0.28s ease; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nbc-main-input      { font-size: 1.1rem;  padding: 14px; }
  .nbc-output-grid     { grid-template-columns: 1fr 1fr; }
  .nbc-output-base-num { font-size: 1.2rem; }
  .nbc-output-value code { font-size: 0.82rem; }
  .nbc-bit-box         { width: 26px; height: 26px; font-size: 0.78rem; }
  .nbc-info-row        { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .nbc-section-card    { padding: 16px; }
}
@media (max-width: 420px) {
  .nbc-output-grid { grid-template-columns: 1fr; }
  .nbc-custom-output-box { min-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .nbc-output-card { animation: none; }
  .nbc-value-updated code { animation: none; }
  .nbc-bit-box,
  .nbc-base-btn,
  .nbc-copy-btn,
  .nbc-icon-btn { transition: none; }
}
