/* =============================================================================
 * ThyroNaut — styles.css
 * AiBx Yellow theme: golden yellow + near-black.
 * Color coding: green = Benign, red = Malignant.
 * =========================================================================== */

:root {
  --bg:              #faf9f5;
  --surface:         #ffffff;
  --border:          #e8e2d0;
  --text:            #1a1a1a;
  --muted:           #6b6459;
  --primary:         #f5b800;
  --primary-hover:   #e0a800;
  --primary-text:    #1a1a1a;
  --benign:          #15803d;
  --benign-bg:       #dcfce7;
  --benign-bar:      #22c55e;
  --malignant:       #b91c1c;
  --malignant-bg:    #fee2e2;
  --malignant-bar:   #ef4444;
  --warn:            #b45309;
  --warn-bg:         #fef3c7;
  --shadow:          0 1px 3px rgba(26,20,0,0.06), 0 4px 16px rgba(26,20,0,0.04);
  --shadow-lg:       0 2px 8px rgba(26,20,0,0.09), 0 8px 28px rgba(26,20,0,0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

a            { color: #92400e; text-decoration: none; }
a:hover      { color: #78350f; text-decoration: underline; }

code {
  background: #fef9e7;
  color: #78350f;
  padding: 0.05em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

/* ---------- Header ---------- */

.site-header {
  background: white;
  border-top: 4px solid var(--primary);
  box-shadow: 0 1px 0 var(--border), 0 2px 16px rgba(26,20,0,0.05);
  padding: 22px 0;
}

.header-brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.header-identity {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.site-logo {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  margin: 0;
}

.logo-thyro { color: #1a1a1a; }
.logo-naut  { color: var(--primary); }

.logo-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  font-weight: 400;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.research-badge {
  display: inline-block;
  background: var(--primary);
  color: #1a1a1a;
  border-radius: 4px;
  padding: 3px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.header-note {
  font-size: 11px;
  color: #a39580;
  margin: 0;
}

@media (max-width: 600px) {
  .header-brand { flex-direction: column; align-items: flex-start; }
  .header-meta  { align-items: flex-start; }
  .container    { padding: 0 20px; }
}

/* ---------- Main layout ---------- */

main.container { padding-top: 28px; padding-bottom: 52px; }
section + section { margin-top: 24px; }

/* ---------- Instructions ---------- */

.instructions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.instructions h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}

.instructions ol {
  padding-left: 22px;
  margin: 0;
  color: #5c5347;
  font-size: 14px;
  line-height: 1.78;
}

.instructions li + li { margin-top: 7px; }
.instructions strong { color: var(--text); }

/* ---------- Slots grid ---------- */

.slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 760px) {
  .slots { grid-template-columns: 1fr; }
}

.slot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.slot.drag {
  border-color: var(--primary);
  background: #fffde7;
}

.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slot-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.slot-status {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.slot-preview {
  min-height: 240px;
  background: #faf8f0;
  border-radius: 10px;
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slot-preview canvas {
  max-width: 100%;
  max-height: 260px;
  border-radius: 6px;
  display: block;
}

.slot-placeholder {
  text-align: center;
  color: var(--muted);
  padding: 6px 4px 2px;
  font-size: 13px;
}

.slot-placeholder p { margin: 0; }

.slot-aspect {
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 500;
}

.slot-aspect.ok {
  color: var(--benign);
  background: var(--benign-bg);
}

.slot-aspect.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: white;
  color: var(--text);
  border-color: #d4cfc3;
}

.btn-secondary:hover:not(:disabled) {
  background: #faf8f0;
  border-color: #b8b0a0;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(26,20,0,0.05);
}

.btn-run {
  background: var(--primary);
  color: var(--primary-text);
  font-size: 15px;
  font-weight: 700;
  padding: 13px 32px;
  border-radius: 10px;
  border: none;
  box-shadow: 0 2px 10px rgba(245,184,0,0.35);
}

.btn-run:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 18px rgba(245,184,0,0.45);
}

/* ---------- Run section ---------- */

.run {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.run-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Results ---------- */

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 760px) {
  .result-grid { grid-template-columns: 1fr; }
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.result-card.empty     { opacity: 0.6; }
.result-card.benign    { border-left: 4px solid var(--benign-bar); }
.result-card.malignant { border-left: 4px solid var(--malignant-bar); }

.result-card h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-label {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.2;
}

.result-card.benign    .result-label { color: var(--benign); }
.result-card.malignant .result-label { color: var(--malignant); }

.result-bar { display: flex; flex-direction: column; gap: 8px; }

.result-row {
  display: grid;
  grid-template-columns: 80px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.bar {
  height: 8px;
  background: #f0ece0;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.benign-bar    span { background: var(--benign-bar); }
.malignant-bar span { background: var(--malignant-bar); }

.prob-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}

.result-detail {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Combined nodule card ---------- */

.nodule-card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.nodule-card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
}

.nodule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 760px) {
  .nodule-grid { grid-template-columns: 1fr; }
}

.nodule-rule {
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.nodule-label {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 4px 0;
  line-height: 1.2;
}

.nodule-label.benign    { color: var(--benign); }
.nodule-label.malignant { color: var(--malignant); }

/* ---------- About ---------- */

.info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 24px;
  box-shadow: var(--shadow);
}

.info h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info ul {
  padding-left: 20px;
  margin: 0;
  color: #5c5347;
  font-size: 13px;
  line-height: 1.75;
}

.info li + li { margin-top: 4px; }
.info strong  { color: var(--text); }

/* ---------- Footer ---------- */

.site-footer {
  background: #1a1a1a;
  color: #a39580;
  padding: 32px 0 28px;
  margin-top: 48px;
  font-size: 13px;
  line-height: 1.65;
}

.site-footer h3 {
  color: var(--primary);
  margin: 0 0 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'IBM Plex Mono', monospace;
}

.disclaimers {
  padding-left: 20px;
  margin: 0 0 20px;
}

.disclaimers li + li  { margin-top: 9px; }
.disclaimers strong   { color: #e8dfc8; }

.site-footer a        { color: #f5b800; text-decoration: none; }
.site-footer a:hover  { color: #ffd740; text-decoration: underline; }

.copyright {
  margin: 16px 0 0;
  font-size: 11px;
  color: #4a4035;
}

/* ---------- Crop modal ---------- */

.crop-overlay,
.capture-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,20,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.crop-dialog {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.crop-dialog h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}

.crop-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.crop-stage {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.crop-canvas { display: block; max-width: 100%; }

.crop-box {
  position: absolute;
  border: 2px dashed white;
  box-shadow: 0 0 0 9999px rgba(26,20,0,0.55);
  cursor: move;
}

.crop-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border: 2px solid #1a1a1a;
  border-radius: 4px;
  cursor: nwse-resize;
}

.crop-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Screen-capture overlay ---------- */

.capture-overlay {
  background: rgba(26,20,0,0.9);
  padding: 0;
}

.capture-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 10;
  flex-wrap: wrap;
}

.capture-label { font-weight: 600; font-size: 14px; }
.capture-hint  { color: var(--muted); font-size: 13px; flex: 1; }

.capture-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.capture-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.capture-video {
  max-width: 96%;
  max-height: 88%;
  border-radius: 8px;
  background: #000;
  margin-top: 56px;
}

.capture-box {
  position: absolute;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 9999px rgba(26,20,0,0.55);
  pointer-events: auto;
  cursor: move;
}

.capture-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border: 2px solid #1a1a1a;
  border-radius: 4px;
  cursor: nwse-resize;
}

/* ---------- Header meta row ---------- */

.header-meta-top {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: rgba(245,184,0,0.12);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Dark theme ---------- */

[data-theme="dark"] {
  --bg:       #141410;
  --surface:  #1f1e18;
  --border:   rgba(245,184,0,0.11);
  --text:     #f0ece0;
  --muted:    #8a7d6a;
  --shadow:   0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.28);
  --shadow-lg: 0 2px 8px rgba(0,0,0,0.5), 0 8px 28px rgba(0,0,0,0.38);
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .site-header {
  background: #1f1e18;
  box-shadow: 0 1px 0 rgba(245,184,0,0.1), 0 2px 16px rgba(0,0,0,0.45);
}

[data-theme="dark"] .logo-thyro { color: #f0ece0; }

[data-theme="dark"] .header-note { color: #6b5f50; }

[data-theme="dark"] a         { color: #f5b800; }
[data-theme="dark"] a:hover   { color: #ffd740; }

[data-theme="dark"] code {
  background: rgba(245,184,0,0.1);
  color: #f5b800;
}

[data-theme="dark"] .instructions ol,
[data-theme="dark"] .info ul { color: #b8aa94; }

[data-theme="dark"] .instructions strong,
[data-theme="dark"] .info strong { color: var(--text); }

[data-theme="dark"] .slot-preview {
  background: #111108;
  border-color: rgba(245,184,0,0.07);
}

[data-theme="dark"] .slot-placeholder { color: #6b5f50; }

[data-theme="dark"] .btn-secondary {
  background: #2a2820;
  color: #f0ece0;
  border-color: rgba(245,184,0,0.15);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: #332f22;
  border-color: rgba(245,184,0,0.28);
}

[data-theme="dark"] .btn-ghost         { color: #8a7d6a; }
[data-theme="dark"] .btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.05); }

[data-theme="dark"] .bar { background: rgba(255,255,255,0.07); }

[data-theme="dark"] .slot.drag {
  border-color: var(--primary);
  background: rgba(245,184,0,0.05);
}

[data-theme="dark"] .result-card h3 { color: #6b5f50; }
[data-theme="dark"] .result-row      { color: #8a7d6a; }
[data-theme="dark"] .prob-val        { color: var(--text); }
[data-theme="dark"] .result-detail   { color: #8a7d6a; }
[data-theme="dark"] .nodule-rule     { color: #8a7d6a; }
[data-theme="dark"] .run-status      { color: #8a7d6a; }

[data-theme="dark"] .site-footer {
  background: #0d0c09;
  color: #8a7d6a;
}

[data-theme="dark"] .disclaimers strong { color: #c4b89a; }
[data-theme="dark"] .copyright          { color: #3a3528; }

[data-theme="dark"] .crop-dialog {
  background: #1f1e18;
}
[data-theme="dark"] .crop-dialog h3  { color: var(--text); }
[data-theme="dark"] .crop-hint       { color: #8a7d6a; }
[data-theme="dark"] .capture-toolbar { background: #1f1e18; }
[data-theme="dark"] .capture-label   { color: var(--text); }
