/* Innovation Suite responsive layer
   Loaded after the legacy inline styles so these pages stay usable on phone,
   tablet, and desktop without changing the Flask/Jinja structure. */

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

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  overflow-x: hidden;
}

img,
svg,
canvas,
iframe,
table {
  max-width: 100%;
}

nav {
  width: 100% !important;
  min-width: 0;
  display: flex !important;
  align-items: center !important;
  gap: clamp(10px, 3vw, 24px) !important;
  padding: 12px clamp(12px, 4vw, 40px) !important;
  min-height: 64px;
}

nav a {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 44px;
  max-width: 46%;
  padding: 0 10px;
  border-radius: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

nav > div {
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(1rem, 3.5vw, 1.5rem) !important;
  line-height: 1.2;
  text-align: right;
  overflow-wrap: anywhere;
}

nav > div span {
  max-width: 100%;
  white-space: normal;
}

.innovation-nav-logo {
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.innovation-nav-mark {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter:
    drop-shadow(0 0 9px rgba(0, 210, 255, 0.20))
    drop-shadow(0 0 12px rgba(124, 58, 237, 0.16));
}

.innovation-nav-wordmark {
  width: clamp(120px, 10vw, 152px);
  display: inline-flex;
}

.innovation-nav-wordmark img {
  width: 100%;
  height: auto;
  display: block;
}

.innovation-wordmark-light {
  display: none !important;
}

.innovation-wordmark-dark {
  display: block !important;
}

[data-theme="light"] .innovation-wordmark-light {
  display: block !important;
}

[data-theme="light"] .innovation-wordmark-dark {
  display: none !important;
}

.innovation-nav-title {
  flex: 1 1 auto !important;
}

.container,
.lab-container {
  width: min(100%, 1200px) !important;
  max-width: 1200px;
  padding: clamp(24px, 5vw, 60px) clamp(14px, 4vw, 30px) !important;
}

header {
  margin-bottom: clamp(28px, 7vw, 60px) !important;
}

h1 {
  font-size: clamp(2rem, 9vw, 3.5rem) !important;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2,
h3,
p,
label,
span {
  min-width: 0;
}

.subtitle,
header p {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.dashboard-grid,
.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important;
  gap: clamp(16px, 4vw, 32px) !important;
}

.card,
.subject-section,
.glass-card,
.content,
.empty-state,
.sim-panel {
  min-width: 0;
  background:
    linear-gradient(145deg, rgba(30, 41, 59, 0.72), rgba(11, 18, 32, 0.88)) !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 50px rgba(0, 0, 0, 0.24);
}

.card {
  min-height: 0 !important;
  padding: clamp(22px, 6vw, 40px) clamp(18px, 5vw, 30px) !important;
  border-radius: clamp(18px, 5vw, 24px) !important;
}

.card h3 {
  font-size: clamp(1.25rem, 5vw, 1.5rem) !important;
  line-height: 1.2;
}

.card .card-content {
  max-height: none !important;
  opacity: 1 !important;
  margin-top: 10px !important;
  overflow: visible !important;
}

.card .launch-btn,
.cta-btn,
.gen-btn,
.primary-btn {
  min-height: 44px;
  max-width: 100%;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.icon-small,
.section-icon {
  flex: 0 0 auto;
}

.subject-section {
  padding: clamp(22px, 5vw, 35px) !important;
  border-radius: clamp(22px, 5vw, 32px) !important;
}

.section-header {
  min-width: 0;
  gap: clamp(10px, 3vw, 15px) !important;
}

.section-header h2 {
  font-size: clamp(1.35rem, 5vw, 1.6rem) !important;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.sim-list,
.controls,
.control-group {
  min-width: 0;
}

.sim-item {
  min-width: 0;
  gap: 12px;
  padding: clamp(14px, 4vw, 18px) clamp(16px, 5vw, 24px) !important;
}

.sim-item > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.sim-item > div {
  flex: 0 0 auto;
}

.status-tag {
  white-space: nowrap;
}

.formula-box {
  max-width: 100%;
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.formula-box * {
  max-width: 100%;
}

.glass-card > div:first-child,
.glass-card > div:last-child {
  flex-wrap: wrap;
  gap: 10px;
}

.glass-card button {
  min-height: 44px;
  max-width: 100%;
}

.tabs {
  width: 100%;
  min-width: 0;
  display: flex !important;
  flex-wrap: nowrap;
  gap: 10px !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px !important;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tab-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 14px !important;
  font-size: clamp(0.9rem, 2.8vw, 1.05rem) !important;
  scroll-snap-align: start;
  white-space: nowrap;
}

.sim-panel {
  min-height: 0 !important;
  padding: clamp(16px, 4vw, 30px) !important;
  overflow: visible;
}

.sim-panel.active {
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr) !important;
  gap: clamp(18px, 4vw, 30px) !important;
}

.sim-viewport {
  width: 100%;
  min-width: 0;
  min-height: 360px;
  overflow: hidden;
}

.controls h2 {
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  line-height: 1.2;
  margin-top: 0;
  overflow-wrap: anywhere;
}

select,
input,
button {
  max-width: 100%;
}

input[type="range"] {
  min-height: 28px;
}

.timeline {
  width: 100%;
}

.timeline-item,
.timeline-item .content {
  min-width: 0;
}

.content h2,
.content p {
  overflow-wrap: anywhere;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-6px) scale(1.01) !important;
  }
}

@media (max-width: 900px) {
  .tabs {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .tab-btn {
    flex: 1 1 150px;
    white-space: normal;
  }

  .sim-panel.active {
    grid-template-columns: 1fr !important;
  }

  .sim-viewport {
    min-height: clamp(280px, 58vw, 420px);
  }
}

@media (max-width: 700px) {
  .timeline::after {
    left: 24px !important;
  }

  .timeline-item,
  .timeline-item:nth-child(even),
  .timeline-item:nth-child(odd) {
    width: 100% !important;
    left: 0 !important;
    padding-left: 56px !important;
    padding-right: 0 !important;
  }

  .timeline-item::after,
  .timeline-item:nth-child(even)::after {
    left: 16px !important;
    right: auto !important;
  }
}

@media (max-width: 560px) {
  nav a span {
    display: none !important;
  }

  nav a {
    width: 44px;
    max-width: 44px;
    padding: 0 !important;
    margin-right: 0 !important;
    justify-content: center;
  }

  nav > div {
    text-align: right;
  }

  .innovation-nav-logo {
    padding: 3px 7px;
    gap: 0 !important;
  }

  .innovation-nav-wordmark {
    display: none !important;
  }

  .container,
  .lab-container {
    padding: 20px 12px 30px !important;
  }

  .card .launch-btn,
  .gen-btn,
  .primary-btn {
    width: 100%;
  }

  .tab-btn {
    flex-basis: calc(50% - 10px);
  }

  .sim-item {
    align-items: flex-start !important;
    flex-direction: column;
  }

  .sim-item > div {
    width: 100%;
    justify-content: space-between;
  }

  .glass-card > div:first-child,
  .glass-card > div:last-child {
    justify-content: flex-start !important;
    align-items: flex-start !important;
  }

  .glass-card button {
    width: 100%;
    justify-content: center;
  }

  .content .source-tag {
    position: static !important;
    display: inline-flex;
    width: fit-content;
    margin: 0 0 10px 8px;
    vertical-align: middle;
  }

  .content h2 span {
    display: block;
    margin-top: 4px;
  }

  #pressure .tank,
  #archimedes .sim-viewport > div,
  #snell-viewport > div,
  #shc .sim-viewport > div,
  .electro-setup,
  .rate-viewport,
  #titration .sim-viewport > div,
  .u-tube,
  .potometer-setup {
    transform: scale(0.82);
    transform-origin: center;
  }
}

@media (max-width: 380px) {
  nav {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  h1 {
    font-size: clamp(1.75rem, 10vw, 2.25rem) !important;
  }

  .card,
  .subject-section,
  .glass-card,
  .sim-panel {
    border-radius: 18px !important;
  }

  .tab-btn {
    flex-basis: 100%;
  }

  #pressure .tank,
  #archimedes .sim-viewport > div,
  #snell-viewport > div,
  #shc .sim-viewport > div,
  .electro-setup,
  .rate-viewport,
  #titration .sim-viewport > div,
  .u-tube,
  .potometer-setup {
    transform: scale(0.72);
  }
}

/* Light mode contrast pass for the Innovation Suite.
   These pages have legacy inline dark styles, so this final scoped layer
   keeps every label, card, and action readable on the prism background. */
[data-theme="light"] body {
  background: var(--page-gradient) !important;
  color: #1a1d3a !important;
}

[data-theme="light"] nav {
  background: rgba(248, 250, 255, 0.88) !important;
  border-bottom-color: rgba(139, 152, 202, 0.24) !important;
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.10) !important;
}

[data-theme="light"] .innovation-nav-logo {
  background: rgba(255, 255, 255, 0.64);
  border-color: rgba(139, 152, 202, 0.20);
}

[data-theme="light"] nav a,
[data-theme="light"] nav .text-gray-400,
[data-theme="light"] .back-link {
  color: #4b5578 !important;
}

[data-theme="light"] nav a:hover,
[data-theme="light"] .back-link:hover {
  color: var(--accent-text) !important;
}

[data-theme="light"] nav > div,
[data-theme="light"] nav .text-white,
[data-theme="light"] nav span,
[data-theme="light"] nav span[style] {
  color: #1a1d3a !important;
  -webkit-text-fill-color: currentColor !important;
  text-shadow: none !important;
}

[data-theme="light"] header,
[data-theme="light"] .container header {
  color: #1a1d3a !important;
}

[data-theme="light"] h1 {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%) !important;
  background-clip: text !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  text-shadow: none !important;
}

[data-theme="light"] .subtitle,
[data-theme="light"] header p,
[data-theme="light"] .container header p {
  color: #66708d !important;
}

[data-theme="light"] header button {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(139, 152, 202, 0.28) !important;
  color: #4b5578 !important;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.08);
}

[data-theme="light"] .container > h2,
[data-theme="light"] .section-title,
[data-theme="light"] .section-header h2,
[data-theme="light"] .controls h2,
[data-theme="light"] .content h2,
[data-theme="light"] .glass-card h2,
[data-theme="light"] .featured-card h2,
[data-theme="light"] .card h3 {
  color: #1a1d3a !important;
  -webkit-text-fill-color: currentColor !important;
  text-shadow: none !important;
}

[data-theme="light"] .container > h2 {
  border-bottom-color: rgba(139, 152, 202, 0.24) !important;
}

[data-theme="light"] .card,
[data-theme="light"] .featured-card,
[data-theme="light"] .subject-section,
[data-theme="light"] .glass-card,
[data-theme="light"] .content,
[data-theme="light"] .empty-state,
[data-theme="light"] .sim-panel {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(239, 244, 255, 0.84)) !important;
  border-color: rgba(139, 152, 202, 0.25) !important;
  color: #1a1d3a !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 18px 48px rgba(102, 126, 234, 0.14) !important;
}

[data-theme="light"] .card:hover,
[data-theme="light"] .featured-card:hover,
[data-theme="light"] .glass-card:hover {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(246, 248, 255, 0.92)) !important;
  border-color: rgba(102, 126, 234, 0.36) !important;
}

[data-theme="light"] .card p,
[data-theme="light"] .featured-card p,
[data-theme="light"] .content p,
[data-theme="light"] .empty-state,
[data-theme="light"] label,
[data-theme="light"] .status-tag {
  color: #5a607a !important;
  text-shadow: none !important;
}

[data-theme="light"] .icon-small {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #1a1d3a !important;
  border: 1px solid rgba(139, 152, 202, 0.20);
  box-shadow: 0 10px 26px rgba(102, 126, 234, 0.10);
}

[data-theme="light"] .card .launch-btn,
[data-theme="light"] .cta-btn,
[data-theme="light"] .gen-btn,
[data-theme="light"] .primary-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border-color: rgba(102, 126, 234, 0.42) !important;
  color: #ffffff !important;
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.22) !important;
}

[data-theme="light"] .card:hover .launch-btn:hover,
[data-theme="light"] .cta-btn:hover,
[data-theme="light"] .gen-btn:hover,
[data-theme="light"] .primary-btn:hover {
  color: #ffffff !important;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(102, 126, 234, 0.30) !important;
}

[data-theme="light"] .sim-viewport,
[data-theme="light"] .formula-box,
[data-theme="light"] .sim-item,
[data-theme="light"] select,
[data-theme="light"] input,
[data-theme="light"] textarea {
  background: rgba(255, 255, 255, 0.88) !important;
  border-color: rgba(139, 152, 202, 0.24) !important;
  color: #1a1d3a !important;
}

[data-theme="light"] .formula-box,
[data-theme="light"] .content [style*="color:#fff"],
[data-theme="light"] .content [style*="color: #fff"],
[data-theme="light"] .glass-card [style*="color:#fff"],
[data-theme="light"] .glass-card [style*="color: #fff"] {
  color: #1a1d3a !important;
}

[data-theme="light"] .formula-box {
  background: rgba(255, 255, 255, 0.88) !important;
  border-color: rgba(139, 152, 202, 0.24) !important;
}

[data-theme="light"] .revision-empty-state,
[data-theme="light"] #suggestion-list > div[style*="text-align:center"],
[data-theme="light"] #suggestion-list > div[style*="text-align: center"] {
  color: #5a607a !important;
  -webkit-text-fill-color: currentColor !important;
  text-shadow: none !important;
}

[data-theme="light"] .topic-badge,
[data-theme="light"] .topic-badge[style],
[data-theme="light"] .glass-card h3[style] {
  color: #1a1d3a !important;
  -webkit-text-fill-color: currentColor !important;
}
