/* ==========================================================================
   Stem Cell Explorer — Global Styles
   2025-October-9th
   Felix Wilton
   ========================================================================== */

/* ===== 1) Design tokens ===== */
:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --surface: #f7f7f7;
  --accent: #0d6efd;
  --radius: 8px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* ===== 2) Reset & base ===== */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  overflow-x: hidden;
  overscroll-behavior: none;
}

img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== 3) Layout containers ===== */
.container {
  width: min(1100px, 92vw);
  margin-inline: auto;
}
.container.narrow { width: min(850px, 92vw); }
.container.full-bleed {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* ===== 4) Header & footer ===== */
.site-header {
  /* non-sticky header */
  background: var(--bg);
  border-bottom: 1px solid #eaeaea;
}
.site-title {
  margin: 0;
  padding: 18px 0;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-footer {
  border-top: 1px solid #eaeaea;
  padding: 18px 0;
  margin-top: 24px;
}

/* ===== 5) Sections ===== */
.section { padding: clamp(16px, 3vw, 28px) 0; }
.content-section .container {}

/* ===== 6) Game section ===== */
.game-section { padding: 0; }

.game-section .game-shell {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  height: clamp(360px, 60vh, 720px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: center;
}

/* Canvas wrapper anchors the fullscreen button relative to the canvas */
.canvas-wrap {
  position: relative;
  display: inline-block;
  line-height: 0; /* remove inline gap */
}

/* Rotate notice overlay (toggled by JS) */
.rotate-notice {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.96);
  color: var(--text);
  text-align: center;
  z-index: 5;
}
.rotate-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid #eaeaea;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid #e1e1e1;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover { background: #f7f7f7; }

/* ===== 7) Content components ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.headshot {
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid #eaeaea;
}

/* Copyright */
.copyright-section { text-align: center; padding: 2rem 0; }
.copyright-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Links */
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
}
.link {
  color: var(--accent);
  text-decoration: none;
  border-radius: 6px;
  padding: 2px 4px;
}
.link:hover, .link:focus-visible { text-decoration: underline; }

/* ===== 8) Unity skin ===== */
#unity-container { position: relative; width: 100%; }

#unity-canvas {
  background: #231F20;
  display: block;
  margin: 0 auto;
}

/* Loading UI */
#unity-loading-bar {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: none;
}
#unity-logo {
  width: 154px; height: 130px;
  background: url('unity-logo-dark.png') no-repeat center / contain;
}
#unity-progress-bar-empty {
  width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px;
  background: url('progress-bar-empty-dark.png') no-repeat center / contain;
}
#unity-progress-bar-full {
  width: 0%; height: 18px; margin-top: 10px;
  background: url('progress-bar-full-dark.png') no-repeat left center / contain;
}

/* Fullscreen control pinned to canvas */
#unity-footer {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  pointer-events: none;
}
#unity-fullscreen-button {
  display: none; /* shown by JS on Desktop/Android */
  pointer-events: auto;
  cursor: pointer;
  width: 38px; height: 38px;
  border: 0;
  border-radius: 8px;
  background: url('fullscreen-button.png') no-repeat center / 22px 22px, #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
#unity-fullscreen-button:focus-visible { outline: 2px solid var(--accent); }

#unity-warning {
  position: absolute; left: 50%; top: 5%; transform: translate(-50%);
  background: white; color: #000;
  padding: 10px; display: none; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ===== 9) Fullscreen state (Desktop + Android) ===== */
body.fs-active { background: #000; }
body.fs-active #unity-container {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  height: 100vh !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 100;
}
body.fs-active .canvas-wrap { width: 100vw; height: 100vh; }
body.fs-active #unity-canvas { display: block; margin: 0 auto; }

/* ===== 10) Responsive rules ===== */

/* 10.a — Mobile portrait: full-width column */
@media (max-width: 900px) and (orientation: portrait) {
  .container,
  .container.narrow,
  .container.full-bleed {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .game-section .game-shell { height: clamp(360px, 70svh, 820px); }
}

/* 10.b — Mobile landscape (phones): centered 90% column */
@media (max-width: 900px) and (orientation: landscape) {
  .container,
  .container.narrow,
  .container.full-bleed {
    width: 90%;
    max-width: none;
    margin-inline: auto;
    padding-left: 0;
    padding-right: 0;
  }
  .game-section .game-shell {
    min-height: 300px;
    height: clamp(300px, 70vh, 720px);
  }
}

/* 10.c — Touch tablets in landscape (iPad etc.) */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .container,
  .container.narrow,
  .container.full-bleed {
    width: 90%;
    max-width: none;
    margin-inline: auto;
    padding-left: 0;
    padding-right: 0;
  }
  /* Use svh to avoid Safari toolbar shrink */
  .game-section .game-shell {
    min-height: 360px;
    height: clamp(360px, 80svh, 820px);
  }
}

.feedback-link-wrap {
  text-align: center;
  margin: 2rem 0;
}

.feedback-link {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0066cc;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s ease;
}

.feedback-link:hover,
.feedback-link:focus {
  color: #004999;
}