/* ═══════════════════════════════════════════
   temperature-converter.css — ChrysoKit
   Tool-specific styles only.
   Hardcoded light + dark values so inputs
   always render with correct contrast.
   ═══════════════════════════════════════════ */

/* ── LIGHT MODE TOKENS ── */
:root {
  --tc-bg:          #fefae0;
  --tc-card:        #fffdf5;
  --tc-input-bg:    #ffffff;
  --tc-input-text:  #1a1208;
  --tc-input-ph:    #a08860;
  --tc-border:      #d9c89a;
  --tc-border-soft: #ece0c0;
  --tc-label:       #5a4a2e;
  --tc-muted:       #7a6545;
  --tc-accent:      #c8924a;
  --tc-accent-fg:   #ffffff;
  --tc-hover:       #f5e8cc;
  --tc-pill:        #ede0c0;
  --tc-pill-text:   #7a6545;
  --tc-ctx-bg:      #ffffff;
  --tc-ctx-border:  #d9c89a;
  --tc-shadow:      rgba(180,140,60,.13);
  --tc-error:       #d94040;
}

/* ── DARK MODE TOKENS ── */
[data-theme="dark"] {
  --tc-bg:          #1a1208;
  --tc-card:        #241a08;
  --tc-input-bg:    #2e2010;
  --tc-input-text:  #f5edd0;
  --tc-input-ph:    #7a6535;
  --tc-border:      #4a3618;
  --tc-border-soft: #3a2c12;
  --tc-label:       #c8aa78;
  --tc-muted:       #9a8050;
  --tc-accent:      #d4a373;
  --tc-accent-fg:   #1a1208;
  --tc-hover:       #3a2c12;
  --tc-pill:        #3a2c12;
  --tc-pill-text:   #c8aa78;
  --tc-ctx-bg:      #2e2010;
  --tc-ctx-border:  #4a3618;
  --tc-shadow:      rgba(0,0,0,.35);
  --tc-error:       #e05b54;
}

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */
.tc-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

/* ════════════════════════════════════════
   3-D THERMOMETER
════════════════════════════════════════ */
.tc-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
  padding-top: .2rem;
}

#thermoCanvas {
  display: block;
  filter: drop-shadow(0 4px 16px var(--tc-shadow));
}

.tc-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--tc-accent);
  background: var(--tc-card);
  border: 1px solid var(--tc-border);
  border-radius: 20px;
  padding: .22rem .75rem;
  white-space: nowrap;
  letter-spacing: .01em;
}

/* ════════════════════════════════════════
   BODY COLUMN
════════════════════════════════════════ */
.tc-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ════════════════════════════════════════
   8-SCALE GRID
════════════════════════════════════════ */
.tc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .85rem;
}

.tc-field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

/* Label row */
.tc-field label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .79rem;
  font-weight: 600;
  color: var(--tc-label);
  line-height: 1;
  cursor: default;
}

/* Unit symbol pill */
.tc-field label em {
  font-style: normal;
  font-size: .7rem;
  font-weight: 500;
  color: var(--tc-pill-text);
  background: var(--tc-pill);
  border-radius: 4px;
  padding: .12rem .38rem;
  margin-left: auto;
}

/* Colour dot */
.tc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, #999);
  flex-shrink: 0;
}

/* Input + copy button row */
.tc-row {
  display: flex;
  gap: .35rem;
}

/* ── THE INPUT BOX ── */
.tc-input {
  flex: 1;
  min-width: 0;
  font-family: 'Inter', ui-monospace, monospace;
  font-size: .975rem;
  font-weight: 500;
  line-height: 1.4;
  padding: .48rem .65rem;
  border-radius: 8px;
  border: 1.5px solid var(--tc-border);
  background: var(--tc-input-bg);
  color: var(--tc-input-text);
  transition: border-color .15s, box-shadow .15s;
  appearance: textfield;
  -moz-appearance: textfield;
}
.tc-input::-webkit-inner-spin-button,
.tc-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tc-input::placeholder { color: var(--tc-input-ph); }
.tc-input:focus {
  outline: none;
  border-color: var(--tc-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc-accent) 22%, transparent);
}
.tc-input.tc-error {
  border-color: var(--tc-error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc-error) 15%, transparent);
}

/* ── COPY BUTTON ── */
.tc-copy {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  flex-shrink: 0;
  border: 1.5px solid var(--tc-border);
  border-radius: 8px;
  background: var(--tc-card);
  color: var(--tc-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  padding: 0;
}
.tc-copy:hover {
  background: var(--tc-accent);
  color: var(--tc-accent-fg);
  border-color: var(--tc-accent);
}
.tc-copy svg { width: 14px; height: 14px; }

/* Inline hint text */
.tc-hint {
  min-height: 1em;
  font-size: .7rem;
  color: var(--tc-muted);
  line-height: 1.35;
}

/* ════════════════════════════════════════
   ACTION BUTTONS
════════════════════════════════════════ */
.tc-actions {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  border: 1.5px solid var(--tc-border);
  background: var(--tc-card);
  color: var(--tc-label);
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
}
.btn-ghost:hover {
  background: var(--tc-hover);
  color: var(--tc-input-text);
  border-color: var(--tc-accent);
}
.btn-ghost svg { width: 14px; height: 14px; }

/* ════════════════════════════════════════
   CONTEXT CARDS
════════════════════════════════════════ */
.tc-ctx {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: .7rem;
}

.tc-ctx-item {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .75rem .9rem;
  border-radius: 10px;
  border: 1px solid var(--tc-ctx-border);
  background: var(--tc-ctx-bg);
}

.tc-ctx-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: .05rem;
}

.tc-ctx-lbl {
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tc-muted);
  margin: 0 0 .18rem;
}

.tc-ctx-val {
  font-size: .81rem;
  font-weight: 600;
  color: var(--tc-input-text);
  margin: 0;
  line-height: 1.35;
}

.tc-bb-swatch {
  width: 30px;
  height: 13px;
  border-radius: 4px;
  margin-top: .38rem;
  border: 1px solid var(--tc-border);
  background: transparent;
  transition: background .4s;
}

/* ════════════════════════════════════════
   COLLAPSIBLE DETAILS PANELS
════════════════════════════════════════ */
.tc-details {
  margin-top: 1rem;
  border: 1px solid var(--tc-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--tc-card);
}

.tc-details summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1.1rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--tc-input-text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--tc-card);
}
.tc-details summary::-webkit-details-marker { display: none; }
.tc-details summary svg { width: 16px; height: 16px; color: var(--tc-accent); flex-shrink: 0; }
.tc-details summary::after {
  content: '↓';
  margin-left: auto;
  font-size: .8rem;
  color: var(--tc-muted);
}
.tc-details[open] summary::after { content: '↑'; }
.tc-details summary:hover { background: var(--tc-hover); }

/* Formulas */
.tc-formulas {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .85rem 1.1rem;
  background: var(--tc-bg);
  border-top: 1px solid var(--tc-border-soft);
}

.tc-frow {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .42rem .65rem;
  border-radius: 6px;
  background: var(--tc-card);
  border: 1px solid var(--tc-border-soft);
}

.tc-frow span {
  font-size: .78rem;
  font-weight: 600;
  color: var(--tc-muted);
  min-width: 72px;
  font-family: ui-monospace, monospace;
}

.tc-frow code {
  font-family: ui-monospace, monospace;
  font-size: .82rem;
  color: var(--tc-input-text);
  background: transparent;
}

/* Reference table */
.tc-table-wrap {
  overflow-x: auto;
  padding: .85rem 1.1rem;
  background: var(--tc-bg);
  border-top: 1px solid var(--tc-border-soft);
}

.tc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.tc-table th {
  text-align: left;
  padding: .5rem .75rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tc-muted);
  background: var(--tc-card);
  border-bottom: 1px solid var(--tc-border);
}

.tc-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--tc-border-soft);
  color: var(--tc-input-text);
}

.tc-table td:not(:first-child) {
  font-family: ui-monospace, monospace;
  font-size: .8rem;
}

.tc-table tbody tr {
  cursor: pointer;
  transition: background .12s;
}
.tc-table tbody tr:hover { background: var(--tc-hover); }
.tc-table tbody tr:last-child td { border-bottom: none; }

/* ════════════════════════════════════════
   QUICK REFS MODAL
════════════════════════════════════════ */
.tc-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.tc-modal.open { display: flex; }

.tc-modal-box {
  background: var(--tc-card);
  border: 1px solid var(--tc-border);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
}

.tc-modal-title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 1rem;
  color: var(--tc-input-text);
}

.tc-modal-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  max-height: 58vh;
  overflow-y: auto;
}

.tc-modal-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem .75rem;
  border-radius: 7px;
  cursor: pointer;
  background: var(--tc-bg);
  border: 1px solid var(--tc-border-soft);
  transition: background .12s;
  gap: .5rem;
}
.tc-modal-list li:hover { background: var(--tc-hover); }

.tc-modal-list .r-name {
  font-size: .84rem;
  font-weight: 500;
  color: var(--tc-input-text);
}
.tc-modal-list .r-val {
  font-size: .77rem;
  font-family: ui-monospace, monospace;
  color: var(--tc-muted);
  white-space: nowrap;
}

.tc-modal-close {
  width: 100%;
  justify-content: center;
}

/* ════════════════════════════════════════
   TOAST
════════════════════════════════════════ */
.tc-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(.5rem);
  background: var(--tc-input-text);
  color: var(--tc-bg);
  padding: .55rem 1.25rem;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 600;
  white-space: nowrap;
}
.tc-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 700px) {
  .tc-layout {
    flex-direction: column;
  }
  .tc-visual {
    flex-direction: row;
    padding-top: 0;
    width: 100%;
    justify-content: flex-start;
  }
  #thermoCanvas {
    width: 48px;
    height: 160px;
  }
  .tc-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .tc-grid {
    grid-template-columns: 1fr;
  }
  .tc-ctx {
    grid-template-columns: 1fr 1fr;
  }
}
