/* ==========================================================================
   Blue Without Blue — Conservation Studio & Vision Lab Stylesheet
   Self-contained, offline, responsive (Desktop & Mobile).
   ========================================================================== */

:root {
  --bg-deep: #11100f;
  --bg-panel: #191715;
  --bg-elevated: #221f1c;
  --bg-input: #2b2723;
  --border-subtle: rgba(226, 188, 128, 0.14);
  --border-strong: rgba(226, 188, 128, 0.34);
  --text-primary: #f4efe6;
  --text-secondary: #bfb6a8;
  --text-muted: #8c8275;
  --accent-ochre: #e09f3e;
  --accent-vermilion: #d94e34;
  --accent-blue-illusion: #6ba3be;
  --accent-olive: #84a34c;
  --success: #7bc47f;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-studio: 0 14px 36px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Header / Atelier Banner */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: radial-gradient(circle at 20% 0%, rgba(224, 159, 62, 0.11), transparent 60%),
              linear-gradient(180deg, #171513 0%, #11100f 100%);
  padding: 1.4rem 1.5rem 1.2rem;
}

.header-inner {
  max-width: 1340px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.brand-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent-ochre);
  margin-bottom: 0.3rem;
}

.palette-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.palette-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.site-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.45rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--text-primary);
}

.site-subtitle {
  margin: 0.25rem 0 0;
  max-width: 720px;
  color: var(--text-secondary);
  font-size: 0.96rem;
}

.header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.studio-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Main Container */
.main-workspace {
  max-width: 1340px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
}

/* Section Headers */
.section-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.65rem;
}

.section-step {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-ochre);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  margin: 0.15rem 0 0;
  font-weight: 600;
}

.section-lead {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 620px;
}

/* ==========================================================================
   STAGE 1: Pinhole Isolation Theatre
   ========================================================================== */
.study-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.study-tab {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  text-align: left;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.study-tab:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.study-tab.active {
  background: linear-gradient(180deg, rgba(224, 159, 62, 0.16), rgba(224, 159, 62, 0.05));
  border-color: var(--accent-ochre);
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.study-tab-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-ochre);
}

.study-tab-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.98rem;
}

.study-tab-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinhole-stage-grid {
  display: grid;
  grid-template-columns: 1.32fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.canvas-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-studio);
}

.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.btn-primary-toggle {
  background: var(--accent-ochre);
  color: #14110e;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn-primary-toggle:hover {
  background: #ebb052;
}

.btn-primary-toggle.isolated-active {
  background: var(--accent-blue-illusion);
  color: #0d1317;
}

.aperture-control-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-elevated);
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  flex: 1;
  min-width: 240px;
}

.aperture-control-group label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.aperture-control-group input[type="range"] {
  flex: 1;
  accent-color: var(--accent-ochre);
  cursor: pointer;
}

.aperture-val-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-ochre);
  min-width: 84px;
  text-align: right;
}

/* Canvas Viewport */
.study-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 640 / 440;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid rgba(224, 159, 62, 0.28);
  background: #141210;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.study-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-floating-hint {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: rgba(244, 239, 230, 0.92);
  background: rgba(17, 16, 15, 0.78);
  backdrop-filter: blur(4px);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Hotspot Bar & Card Tone Controls */
.canvas-subbar {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.hotspot-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.hotspot-label-prefix {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.hotspot-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.3rem 0.68rem;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.hotspot-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.hotspot-btn.active {
  background: rgba(107, 163, 190, 0.18);
  border-color: var(--accent-blue-illusion);
  color: var(--text-primary);
  font-weight: 600;
}

.card-tone-selector {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.tone-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.24rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.tone-btn.active {
  border-color: var(--accent-ochre);
  color: var(--text-primary);
  background: var(--bg-input);
}

/* Right Column: Spectro-Colorimeter & Retinex Inspector */
.inspector-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-studio);
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.study-meta-box h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin: 0 0 0.25rem;
}

.study-meta-box p {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-secondary);
}

.swatch-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.swatch-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.swatch-panel-header {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.swatch-preview-box {
  height: 64px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  color: #fff;
}

.swatch-classification {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-primary);
}

.swatch-metrics {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Retinex Blue Induction Meter */
.induction-meter-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.9rem;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}

.meter-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.meter-score {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-blue-illusion);
}

.meter-track {
  width: 100%;
  height: 10px;
  background: #121110;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #6e6f6e 0%, #5b829c 50%, #4692c7 100%);
  border-radius: 999px;
  transition: width 0.18s ease;
}

.meter-caption {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.hotspot-note-box {
  background: rgba(224, 159, 62, 0.08);
  border-left: 3px solid var(--accent-ochre);
  padding: 0.6rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   STAGE 2: Four-Pigment Kubelka-Munk Mixing Studio & Target Challenges
   ========================================================================== */
.mixing-studio-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr;
  gap: 1.25rem;
  align-items: start;
}

.tubes-card, .mixing-canvas-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-studio);
}

/* Challenges Bar */
.challenges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.challenge-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  text-align: left;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
}

.challenge-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.challenge-card.active {
  border-color: var(--accent-ochre);
  background: linear-gradient(180deg, rgba(224, 159, 62, 0.15), rgba(224, 159, 62, 0.04));
  color: var(--text-primary);
}

.challenge-card.solved {
  border-color: var(--success);
}

.challenge-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--accent-ochre);
}

.challenge-status-pill {
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  font-size: 0.66rem;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
}

.challenge-card.solved .challenge-status-pill {
  background: rgba(123, 196, 127, 0.22);
  color: var(--success);
  font-weight: 700;
}

.challenge-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-primary);
}

.challenge-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 0;
}

/* Pigment Tube Sliders */
.tube-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tube-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.68rem 0.85rem;
}

.tube-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.tube-title-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.tube-daub {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.25);
}

.tube-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.tube-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.tube-pct {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-ochre);
}

.tube-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tube-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--accent-ochre);
  cursor: pointer;
}

.tube-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Surround Context Controls in Stage 2 */
.surround-control-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.9rem;
}

.surround-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.72rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.14s ease;
}

.btn-secondary:hover {
  border-color: var(--accent-ochre);
  background: rgba(224, 159, 62, 0.14);
}

/* Mixing & Border Contrast Canvas */
.mix-canvas-wrap {
  width: 100%;
  aspect-ratio: 620 / 320;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #141210;
  margin-bottom: 0.85rem;
}

.mix-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Challenge Evaluation Banner */
.challenge-eval-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.95rem;
  margin-bottom: 0.9rem;
}

.challenge-eval-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.challenge-eval-title {
  font-weight: 700;
  font-size: 0.92rem;
}

.challenge-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(224, 159, 62, 0.16);
  color: var(--accent-ochre);
}

.challenge-badge.pass {
  background: rgba(123, 196, 127, 0.22);
  color: var(--success);
  font-weight: 700;
}

.criteria-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.criterion-item {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  padding: 0.35rem 0.55rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-secondary);
  border-left: 3px solid var(--text-muted);
}

.criterion-item.met {
  border-left-color: var(--success);
  color: var(--text-primary);
}

/* Spectral Reflectance & KM vs Naive RGB Comparison */
.spectral-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 0.85rem;
  align-items: stretch;
}

.spectrum-box, .km-vs-rgb-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

.box-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.spectrum-canvas-wrap {
  width: 100%;
  aspect-ratio: 420 / 210;
}

.spectrum-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.km-rgb-swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.45rem;
}

.mini-swatch-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.mini-swatch-color {
  height: 44px;
  border-radius: 4px;
  margin-bottom: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.mini-swatch-title {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.mini-swatch-data {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Footer / Historical & Scientific Notes */
.atelier-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.note-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
}

.note-card h4 {
  font-family: var(--font-serif);
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--accent-ochre);
}

.note-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .pinhole-stage-grid,
  .mixing-studio-grid,
  .spectral-grid {
    grid-template-columns: 1fr;
  }
  .study-tabs,
  .challenges-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .atelier-notes-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .site-header {
    padding: 1rem;
  }
  .main-workspace {
    padding: 1rem 0.9rem 2.5rem;
  }
  .study-tabs,
  .challenges-grid,
  .swatch-comparison-grid {
    grid-template-columns: 1fr;
  }
  .canvas-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary-toggle {
    justify-content: center;
  }
}
