/* =======================================================================
   123TRIG — CLEAN GLOBAL STYLESHEET
   ======================================================================= */

/* 🎨 COLOR PALETTE */
:root {
  --color-primary: #234;
  --color-accent: #f57c00;
  --color-bg-light: #f3f4f8;
  --color-bg-green: #e9f7f0;
  --color-bg-purple: #f5f3ff;
  --color-bg-blue: #e0f2fe;
  --color-bg-space: #d1fae5;
  --color-text-dark: #0f172a;
  --color-text-muted: #445;
  --radius: 8px;
}

/* 🧱 RESET & GLOBAL TEXT */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
p,
span,
div {
  white-space: normal;
}

body {
  font-family: "Segoe UI", sans-serif;
  background: #f7f8fa;
  padding: 2rem;
  margin: 0 auto;
  min-height: 100vh;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
}

h1 {
  text-align: center;
  font-size: 2.2rem;
  letter-spacing: 1px;
  margin-bottom: 1.5rem;
  color: var(--color-primary);
  font-weight: 800;
}

a {
  color: #1a8;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.about-block {
  max-width: 720px;
  margin: 4rem auto;
  text-align: center;
  line-height: 1.7;
}
.about-block p {
  margin-bottom: 1.2rem;
  color: var(--color-text-muted);
}

.contact-block {
  max-width: 720px;
  margin: 4rem auto;
  text-align: center;
  line-height: 1.7;
}
.contact-block p {
  margin-bottom: 1.2rem;
  color: var(--color-text-muted);
}

.terms-block {
  max-width: 720px;
  margin: 4rem auto;
  text-align: center;
  line-height: 1.7;
}
.terms-block p {
  margin-bottom: 1.2rem;
  color: var(--color-text-muted);
}

.privacy-block {
  max-width: 720px;
  margin: 4rem auto;
  text-align: center;
  line-height: 1.7;
}
.privacy-block p {
  margin-bottom: 1.2rem;
  color: var(--color-text-muted);
}


/* =======================================================================
   🚀 HERO SECTION
   ======================================================================= */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 2rem auto 3rem;
  padding: 1rem;
  width: 100%;
  max-width: 800px;
  background: radial-gradient(circle at top, #eef6ff 0%, #ffffff 70%);
  border-radius: 8px;
  box-sizing: border-box;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--color-primary);
}

.tagline {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--color-accent);
  margin-top: 0.5rem;
  margin-bottom: 0.8rem;
}

.desc {
  font-size: 1.05rem;
  color: #345;
  line-height: 1.6;
}

/* =======================================================================
   🧭 TOC (Collapsible Sidebar)
   ======================================================================= */
#toc {
  position: fixed;
  top: 70px;
  left: 0;
  max-width: 280px;
  background: #f9f9fb;
  color: #222;
  border-right: 2px solid #ccc;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 0 10px 10px 0;
  z-index: 9999;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  font-family: "Segoe UI", sans-serif;
}

#toc.toc-ready.open {
  transform: translateX(0);
}

/* Handle */
#toc > #toc-handle {
  position: absolute;
  left: 100%;
  top: 10%;
  background: #234;
  color: #fff;
  border: none;
  padding: 0.5rem 0.8rem;
  border-radius: 0 8px 8px 0;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.2);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 1px;
}

#toc ul {
  list-style: none;
  margin: 0;
  padding: 1rem 1.2rem;
}
#toc li {
  margin: 0.25rem 0;
}
#toc a {
  color: #234;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
#toc a:hover,
#toc a.active {
  color: #0077cc;
  font-weight: 600;
}
#toc ul ul {
  padding-left: 1.2rem;
  border-left: 1px solid #ddd;
  margin-left: 0.5rem;
}

/* Mobile */
@media (max-width: 900px) {
  #toc {
    display: block !important;
    transform: translateX(-100%);
  }
  #toc.toc-ready.open {
    transform: translateX(0);
  }
  #toc > #toc-handle {
    display: block !important;
  }
}
@media (max-width: 750px) {
  #toc {
    max-width: 240px;
    top: 60px;
  }
}

/* =======================================================================
   📐 LAYOUT SYSTEM
   ======================================================================= */
.layout-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  padding: 0 1.5rem;
}
.layout {
  display: flex;
  flex-direction: row;
  gap: 1.7rem;
  flex-wrap: wrap;
}

/* =======================================================================
   🧮 CARDS
   ======================================================================= */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(32, 56, 85, 0.1),
    0 0.5px 1.5px rgba(0, 0, 0, 0.04);
  padding: 2.1rem 2.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
  min-height: 100px;
}
.card:hover {
  box-shadow: 0 8px 36px rgba(32, 56, 85, 0.16),
    0 1.5px 3.5px rgba(0, 0, 0, 0.04);
}
.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #264278;
}

/* =======================================================================
   ✏️ INPUTS, FORMULAS, RESULTS — REFACTORED + KATEX INLINE FIX
   ======================================================================= */

/* 🧩 Shared flex sizing for all columns */
.diagram,
.inputs-col,
.formulas-col,
.results-col {
  flex: 1 1 220px;
  min-width: 160px;
}

/* 🧭 Diagram container (centered SVG or image) */
.diagram {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 🧾 Input layout */
.inputs-col {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.inputs-col label {
  min-width: 70px;
  font-size: 1em;
  color: #233d4d;
}

.inputs-col input {
  width: 76px;
  border: 1.2px solid #e1e5ee;
  background: #f7f7fa;
  border-radius: 8px;
  padding: 0.18em 0.45em;
  font-size: 1em;
  outline: none;
  transition: border 0.2s;
}

.inputs-col input:focus {
  border: 1.5px solid #2875fa;
  background: #eef4ff;
}

/* =======================================================================
   🧮 FORMULA + RESULT BOXES
   ======================================================================= */
.formulas-col,
.results-col {
  position: relative;
  padding: 2rem 0.9em 1.1rem;
  border-radius: 9px;
  font-size: 1.1rem;
}

/* 🧮 Formulas Box */
.formulas-col {
  /* font-family: "Fira Mono", monospace; */
  color: #697a98;
  background: var(--color-bg-light);
}

/* ✅ Results Box */
.results-col {
  /* font-family: "Fira Mono", monospace; */
  font-weight: bold;
  color: var(--color-primary);
  background: var(--color-bg-green);
}

/* =======================================================================
   💡 INLINE FORMULA FIX (no stacking / perfect alignment)
   ======================================================================= */

/* each formula line stays horizontal, but each line is stacked */
.formulas-col > span:not([id]),
.results-col > span:not([id]) {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 4px 0;
  line-height: 1.4;
}

/* labels + inner spans remain inline */
.formulas-col > span span,
.results-col > span span {
  display: inline;
  vertical-align: middle;
}

/* =======================================================================
   🏷️ BOX LABELS (Formulas / Results)
   ======================================================================= */


.formulas-col .label,
.results-col .label {
  position: absolute;
  top: 0rem;
  left: 0rem;
  font-weight: 1000;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.formulas-col .label {
  color: #64748b;
  background: var(--color-bg-light);
}

.results-col .label {
  color: var(--color-text-dark);
  background: var(--color-bg-green);
}


/* =======================================================================
   💬 DESCRIPTIONS & HINTS
   ======================================================================= */
.figure-description {
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: #444;
}
.figure-hint {
  margin-top: 0.6em;
  margin-bottom: 1rem;
  font-size: 0.85em;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* =======================================================================
   🌈 INTRO SECTIONS
   ======================================================================= */
.intro-section {
  border-radius: 12px;
  padding: 1.6rem 1.8rem;
  margin: 2rem auto;
  max-width: 900px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
}
.intro-section.flatland {
  background: linear-gradient(135deg, var(--color-bg-purple) 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe;
}
.intro-section.space {
  background: linear-gradient(
    135deg,
    var(--color-bg-blue) 0%,
    var(--color-bg-space) 100%
  );
  border: 1px solid #bae6fd;
}

/* =======================================================================
   🧭 CONE POPUP (Three.js Overlay)
   ======================================================================= */
#ui,
#sideCounter,
#cameraInfo,
#title {
  position: absolute;
  color: white;
  font-family: sans-serif;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px;
  border-radius: 6px;
  z-index: 1;
}
#ui {
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}
#sideCounter {
  top: 50px;
  left: 10px;
}
#speedSlider {
  width: 120px;
}
#canvasContainer {
  width: 100%;
  height: 100%;
  flex: 1;
  pointer-events: auto;
}
#popupContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
#popupInner {
  position: relative;
  width: 90vw;
  height: 90vh;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
}
#popupInner button,
#closeBtn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 2;
}

/* =======================================================================
   ⚙️ UTILITIES
   ======================================================================= */
.text-center {
  text-align: center;
}
.hidden {
  display: none !important;
}
.mt-2 {
  margin-top: 0.5rem;
}
.mb-2 {
  margin-bottom: 0.5rem;
}
[id] {
  scroll-margin-top: 100px;
}

html,
body {
  overflow-x: hidden;
  width: 100%;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .bmc-button img {
    height: 42px;
    width: 150px;
  }
  .footer-links a {
    display: inline-block;
    margin: 0.3rem 0.4rem;
  }
}

/* === SCOPED HEADER (no conflicts) === */
#site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: rgba(29, 29, 31, 0.72); /* semi-transparent dark glass */
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  color: #f5f5f7;
  z-index: 1000;
  display: flex;
  align-items: center;
}

#site-nav .nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#site-nav .logo {
  font-weight: 600;
  font-size: 1.1rem;
  color: #f5f5f7;
  text-decoration: none;
}

#site-nav .nav-links a {
  margin: 0 0.8rem;
  text-decoration: none;
  color: #d2d2d7;
  font-weight: 500;
  transition: color 0.2s ease;
}

#site-nav .nav-links a:hover {
  color: #fff;
}

#site-nav .lang-select select {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  color: #d2d2d7;
  outline: none;
}

#site-nav #menuToggle {
  display: none;
  font-size: 1.6rem;
  background: none;
  border: none;
  color: #f5f5f7;
  cursor: pointer;
}

/* Mobile */
@media (max-width: 768px) {
  #site-nav .nav-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.5rem 1rem;
  }
  #site-nav .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    text-align: center;
    padding: 1rem 0;
  }
  #site-nav .nav-links a {
    display: block;
    margin: 0.4rem 0;
  }
  #site-nav #menuToggle {
    display: block;
  }
  #site-nav.nav.open .nav-links {
    display: flex;
  }
}

.content {
  margin-top: 56px;
}

/* === GLASS FOOTER (Apple-style mirror) === */
#site-footer {
  position: relative;
  background: rgba(255, 255, 255, 0.75); /* translucent white glass */
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  color: #333;
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 1rem;
  z-index: 10;
}

#site-footer .footer-links,
#site-footer .bmc-button,
#site-footer .footer-credit {
  margin: 0.7rem 0;
}

#site-footer .footer-links a {
  margin: 0 0.6rem;
  text-decoration: none;
  color: #444;
  transition: color 0.2s ease;
}

#site-footer .footer-links a:hover {
  color: var(--color-accent);
}

#site-footer .bmc-button img {
  height: 50px;
  width: 180px;
  border-radius: 8px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#site-footer .bmc-button img:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

#site-footer .footer-credit {
  font-style: italic;
  opacity: 0.8;
  margin-top: 0.5rem;
}

#site-footer p {
  margin: 0.5rem 0;
}

@media (max-width: 480px) {
  #site-footer .bmc-button img {
    height: 42px;
    width: 150px;
  }
  #site-footer .footer-links a {
    display: inline-block;
    margin: 0.3rem 0.4rem;
  }
}

.bmc-button {
  text-align: center;
}

.bmc-button img {
  height: 50px;
  width: 180px;
  border-radius: 8px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.bmc-button img:hover {
  transform: scale(1.05);
  opacity: 0.9;
}
