/* ==========================================================
   Gibson Interactive Lab — Liquid Glass theme (light)
   Apple の Liquid Glass / iOS ライト外観を参照:
   白磨りガラスのレイヤー、淡いパステルの背景ブロブ、
   青アクセント(#0071e3 系)、緑トグル、白ピルのセグメント。
   ========================================================== */

:root {
  --bg0: #eef1f7;
  --bg1: #f6f8fc;
  --text: #1d1d1f;
  --text-dim: rgba(60, 60, 67, 0.66);
  --text-faint: rgba(60, 60, 67, 0.4);
  --stroke: rgba(20, 30, 50, 0.1);
  --stroke-bright: rgba(20, 30, 50, 0.18);
  --accent: #0071e3;
  --accent2: #5e5ce6;
  --mint: #1e9d5a;
  --coral: #e8503f;
  --radius: 24px;
  --radius-sm: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  min-height: 100vh;
  background: var(--bg0);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  overflow-x: hidden;
}

/* ---------- animated backdrop ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 75% -10%, #ffffff 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 70%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(95px);
  opacity: 0.55;
  animation: drift 28s ease-in-out infinite alternate;
}

.blob.b1 {
  width: 620px;
  height: 620px;
  left: -160px;
  top: -180px;
  background: radial-gradient(circle at 35% 35%, #b5d4f8, transparent 70%);
}

.blob.b2 {
  width: 540px;
  height: 540px;
  right: -140px;
  top: -60px;
  background: radial-gradient(circle at 40% 40%, #d4c9f6, transparent 70%);
  animation-delay: -9s;
}

.blob.b3 {
  width: 600px;
  height: 600px;
  left: 30%;
  bottom: -280px;
  background: radial-gradient(circle at 50% 35%, #b8e7e0, transparent 70%);
  animation-delay: -17s;
}

@keyframes drift {
  to {
    transform: translate(70px, 50px) scale(1.14);
  }
}

@media (prefers-reduced-motion: reduce) {
  .blob {
    animation: none;
  }
}

/* ---------- glass surface ---------- */

.glass {
  position: relative;
  background: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.78),
    rgba(255, 255, 255, 0.55) 45%,
    rgba(255, 255, 255, 0.68)
  );
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow:
    0 24px 60px rgba(40, 55, 90, 0.14),
    0 1px 2px rgba(40, 55, 90, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.55), transparent 30%);
  pointer-events: none;
}

/* ---------- page layout ---------- */

.page {
  max-width: 1500px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 14px clamp(14px, 2.4vw, 32px) 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s ease;
}
.back-link:hover { color: var(--accent); }

.app-header {
  padding: 2px 6px 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.app-header > div {
  min-width: 0;
}

.eyebrow,
.module-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.app-header h1 {
  font-size: clamp(20px, 2.2vw, 27px);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.3;
  background: linear-gradient(92deg, #1d1d1f 10%, #0071e3 60%, #5e5ce6 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  flex: 1;
  min-width: 280px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}

@media (max-height: 760px) {
  .lead {
    display: none;
  }
}

/* ---------- module tabs ---------- */

.module-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  gap: 10px;
}

.tab-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 7px 12px 6px;
  text-align: left;
  color: var(--text-dim);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.42));
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
  box-shadow: 0 2px 10px rgba(40, 55, 90, 0.08);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab-button:hover {
  transform: translateY(-2px);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(40, 55, 90, 0.14);
}

.tab-button span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tab-button small {
  display: block;
  margin-top: 1px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.tab-button[aria-selected="true"] {
  color: #ffffff;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  border-color: transparent;
  box-shadow:
    0 10px 26px rgba(10, 100, 230, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.tab-button[aria-selected="true"] small {
  color: rgba(255, 255, 255, 0.72);
}

/* ---------- main lab layout ---------- */

.lab-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(290px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "canvas info"
    "controls info";
  gap: 14px;
  align-items: stretch;
}

.canvas-panel {
  grid-area: canvas;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* キャンバスの収まる領域(レターボックス中央寄せ) */
.canvas-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(20, 30, 50, 0.08),
    0 10px 32px rgba(40, 55, 90, 0.16);
}

#labCanvas {
  position: relative;
  z-index: 2;
  display: block;
  max-width: 100%;
  background: #e9eef6;
  touch-action: none;
}

/* WebGL モジュール時は 2D キャンバスを透明な注釈レイヤーにする */
#labCanvas.webgl-under {
  background: transparent;
}

.webgl-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 6px 16px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(40, 55, 90, 0.14);
  -webkit-backdrop-filter: blur(14px) saturate(170%);
  backdrop-filter: blur(14px) saturate(170%);
  pointer-events: none;
}

.canvas-note {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-faint);
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- info panel ---------- */

.info-panel {
  grid-area: info;
  min-height: 0;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.info-panel h2 {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.module-subtitle {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: -8px;
}

.info-panel > p {
  color: var(--text-dim);
  font-size: 14px;
}

.info-panel section {
  border-top: 1px solid rgba(20, 30, 50, 0.09);
  padding-top: 12px;
}

.info-panel h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mint);
  margin-bottom: 6px;
}

.info-panel section p,
.info-panel li {
  font-size: 13.5px;
  color: var(--text-dim);
}

.info-panel ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-panel li::marker {
  color: var(--accent);
}

/* ---------- controls ---------- */

.controls-panel {
  grid-area: controls;
  padding: 12px 18px 14px;
}

.controls-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.controls-heading h2 {
  font-size: 14px;
  font-weight: 800;
}

.reset-button {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(20, 30, 50, 0.12);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  box-shadow: 0 2px 8px rgba(40, 55, 90, 0.08);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.reset-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(10, 100, 230, 0.18);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 18px;
  align-items: center;
}

.control label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.control output {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* range slider */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(10, 132, 255, 0.55), rgba(94, 92, 230, 0.45));
  box-shadow: inset 0 1px 2px rgba(40, 55, 90, 0.18);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  border: 0.5px solid rgba(20, 30, 50, 0.12);
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(40, 55, 90, 0.3), 0 0 0 4px rgba(10, 132, 255, 0.08);
  transition: box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 3px 8px rgba(40, 55, 90, 0.3), 0 0 0 7px rgba(10, 132, 255, 0.14);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(10, 132, 255, 0.55), rgba(94, 92, 230, 0.45));
}

input[type="range"]::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 0.5px solid rgba(20, 30, 50, 0.12);
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(40, 55, 90, 0.3);
}

/* toggle (checkbox) — iOS スイッチ風 */

.checkbox-control {
  display: flex !important;
  flex-direction: row;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  cursor: pointer;
}

.checkbox-control input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.22);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.22s ease;
}

.checkbox-control input::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  translate: 0 -50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 0 1px rgba(0, 0, 0, 0.12);
  transition: left 0.22s ease;
}

.checkbox-control input:checked {
  background: #34c759;
}

.checkbox-control input:checked::before {
  left: 19px;
}

/* segmented control — iOS セグメント風(白ピル) */

.segmented-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: rgba(120, 120, 128, 0.14);
}

.segmented button {
  flex: 1;
  padding: 6px 6px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.06);
}

/* plain glass button */

.plain-button {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  width: 100%;
  color: var(--accent);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(20, 30, 50, 0.12);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  box-shadow: 0 2px 8px rgba(40, 55, 90, 0.08);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.plain-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(10, 100, 230, 0.16);
}

select {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

select option {
  background: #ffffff;
  color: var(--text);
}

/* ---------- responsive ---------- */

@media (max-width: 1020px) {
  .page {
    height: auto;
    overflow: visible;
  }

  .lab-layout {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "canvas"
      "controls"
      "info";
  }

  .canvas-frame {
    min-height: 300px;
  }

  .module-tabs {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}
