/* =========================================================
   d-Orbital / Ligand Field Visualizer — styles
   Everything is scoped under .dorb-widget so this can be
   dropped into an existing site without touching global
   tags/classes (html, body, .row, .panel, .label, select,
   input[type=range], h1, hr, etc. are all common names that
   site frameworks like Bootstrap already use — scoping avoids
   any collision).
========================================================= */

.dorb-widget{
  --bg: #05070b;
  --panel-bg: rgba(13, 17, 23, 0.86);
  --panel-border: rgba(255,255,255,0.08);
  --text: #e6edf3;
  --text-dim: #d5dce3;
  --text-faint: #a7b0bc;
  --track-off: #1c2430;

  --c-dz2:   #3b82f6;
  --c-dx2y2: #ef4444;
  --c-dxy:   #22c55e;
  --c-dxz:   #f59e0b;
  --c-dyz:   #a855f7;

  --c-ligand: #38bdf8;
  --c-psigma: #f5f0e6;
  --c-ppi1: #2dd4bf;
  --c-ppi2: #f472b6;

  --c-s:   #fbbf24;
  --c-cpz: #6366f1;
  --c-cpx: #fb7185;
  --c-cpy: #4ade80;

  --c-shell: #7dd3fc;
}

.dorb-widget, .dorb-widget *{ box-sizing: border-box; }

.dorb-widget{
  position: relative;
  width: 100%;
  height: min(920px, 88vh);
  min-height: 620px;
  margin-bottom: 36px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  border: 5px solid RGB(240, 238, 243);
  border-radius: 5px;
  overflow: hidden;
}

/* Fullscreen should be edge-to-edge - no card chrome. */
.dorb-widget.is-fullscreen{
  margin: 0;
  border: none;
  border-radius: 0;
}

/* Defensive sizing for the real Fullscreen API - most browsers already
   force a fullscreen element to fill the screen via their UA stylesheet,
   this just makes sure the corners/shadow don't look odd if they don't. */
.dorb-widget:fullscreen,
.dorb-widget:-webkit-full-screen{
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

/* Fallback "maximize" mode for environments where the real Fullscreen
   API is unavailable or blocked (e.g. some sandboxed embeds). */
.dorb-widget.is-fullscreen-fallback{
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  z-index: 9999;
}

.dorb-widget ::selection{ background: rgba(59,130,246,0.3); }

/* ---- toolbar (fullscreen button) ---- */
.dorb-toolbar{
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 14px;
  background: rgba(8,10,15,0.72);
  border-bottom: 1px solid var(--panel-border);
  position: relative;
  z-index: 7;
}
.is-fullscreen .dorb-toolbar{
  position: absolute;
  top: 14px; right: 16px;
  padding: 0;
  background: none;
  border-bottom: none;
  z-index: 7;
}

.dorb-fullscreen-btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.dorb-fullscreen-btn:hover{
  color: var(--text);
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
}

/* ---- top control bar ---- */
.dorb-topbar{
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  background: rgba(8,10,15,0.72);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  position: relative;
  z-index: 2;
  overflow-x: auto;
  overflow-y: hidden;
}

.dorb-topbar::-webkit-scrollbar{ height: 6px; }
.dorb-topbar::-webkit-scrollbar-thumb{ background: rgba(255,255,255,0.15); border-radius: 3px; }

.dorb-col{
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 12px;
}

.dorb-panel{
  flex: 1 1 264px;
  width: 250px;
  min-width: 248px;
  max-width: 310px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px 16px 14px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.35);
}

/* ---- fullscreen layout: panels move to a left column / right column,
   the top bar becomes a transparent overlay so the viewport fills the
   whole widget behind it ---- */
.is-fullscreen .dorb-topbar{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0;
  padding: 60px 20px 20px;
  background: none;
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  max-height: none;
  overflow: visible;
  pointer-events: none;
}
.is-fullscreen .dorb-col{
  flex-direction: column;
  flex: 0 0 auto;
  gap: 14px;
  pointer-events: none;
}
.is-fullscreen .dorb-panel{
  flex: 0 0 auto;
  width: 288px;
  pointer-events: auto;
}

/* ---- 3d viewport (fills remaining space below the top bar) ---- */
.dorb-viewport{
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background:
    radial-gradient(ellipse at 65% 35%, rgba(59,130,246,0.06), transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(168,85,247,0.05), transparent 50%),
    var(--bg);
}

.dorb-viewport canvas{ display: block; }

/* ---- label renderer output (axis tags) ---- */
.dorb-axis-label{
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(5,7,11,0.55);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(0,0,0,0.6);
}

.dorb-eyebrow{
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin: 0 0 2px;
}

.dorb-widget h1{
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.dorb-section-label{
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 14px 0 8px;
}
.dorb-section-label:first-of-type{ margin-top: 0; }

.dorb-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 2px;
}

.dorb-row .dorb-label{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text);
}

.dorb-swatch{
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--sw-color, transparent);
  background: linear-gradient(135deg, var(--sw-color) 50%, color-mix(in srgb, var(--sw-color) 40%, black) 50%);
}

/* toggle switch */
.dorb-switch{ position: relative; width: 34px; height: 18px; flex-shrink: 0; cursor: pointer; }
.dorb-switch input{ opacity: 0; width: 0; height: 0; position: absolute; }
.dorb-toggle-track{
  position: absolute; inset: 0;
  background: var(--track-off);
  border-radius: 9px;
  transition: background .18s ease, box-shadow .18s ease;
}
.dorb-toggle-track::before{
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  background: #5b6572;
  border-radius: 50%;
  transition: transform .18s ease, background .18s ease;
}
.dorb-switch input:checked + .dorb-toggle-track{
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}
.dorb-switch input:checked + .dorb-toggle-track::before{
  transform: translateX(16px);
  background: #fff;
}

.dorb-hr{
  border: none;
  border-top: 1px solid var(--panel-border);
  margin: 12px 0 4px;
}

#dorb-reset-btn{
  width: 100%;
  margin-top: 12px;
  padding: 8px 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s ease;
}
#dorb-reset-btn:hover{
  color: var(--text);
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07);
}

.dorb-legend{
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--text-faint);
}
.dorb-legend-item{ display: flex; align-items: center; gap: 6px; }
.dorb-legend-dot{ width: 8px; height: 8px; border-radius: 50%; }

/* ---- geometry select ---- */
.dorb-select-wrap{ position: relative; }
.dorb-select-wrap::after{
  content: '▾';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 10px;
  pointer-events: none;
}
.dorb-widget select{
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--track-off);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 30px 9px 11px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.dorb-widget select:hover{ border-color: rgba(255,255,255,0.2); }
.dorb-widget select:focus{ outline: none; border-color: var(--c-ligand); }
.dorb-widget select option{ background: #0c1119; color: var(--text); }

/* ---- range sliders ---- */
.dorb-range-row{ margin-top: 4px; }
.dorb-range-row .dorb-row{ padding-bottom: 0; }
.dorb-range-row .dorb-value{
  font-size: 11.5px;
  font-weight: 600;
}
.dorb-widget input[type="range"]{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin-top: 10px;
  background: var(--track-off);
  border-radius: 2px;
  outline: none;
}
.dorb-widget input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--c-ligand);
  box-shadow: 0 0 10px var(--c-ligand);
  cursor: pointer;
  border: 2px solid #0c1119;
}
.dorb-widget input[type="range"]::-moz-range-thumb{
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--c-ligand);
  box-shadow: 0 0 10px var(--c-ligand);
  cursor: pointer;
  border: 2px solid #0c1119;
}
#dorb-shell-opacity-slider::-webkit-slider-thumb{ background: var(--c-shell); box-shadow: 0 0 10px var(--c-shell); }
#dorb-shell-opacity-slider::-moz-range-thumb{ background: var(--c-shell); box-shadow: 0 0 10px var(--c-shell); }

.dorb-note{
  font-size: 10px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 10px 2px 0;
}

#dorb-hint{
  position: absolute;
  bottom: 16px; left: 20px;
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  z-index: 1;
}
