/* ============================================================
   THM·Lab — Thermo-Hydro-Mechanical processes in porous media
   ============================================================ */

:root {
  --bg: #0a0f1f;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8edf6;
  --muted: #93a1b8;
  --t: #ff9e64;   /* thermal  */
  --h: #4cc9f0;   /* hydraulic */
  --m: #54d68c;   /* mechanical */
  --accent: #4cc9f0;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: "Sora", "Inter", sans-serif; line-height: 1.25; }
h3 { font-size: 1.18rem; margin: 1.1em 0 0.5em; }
h3:first-child { margin-top: 0; }
h4 { margin: 0 0 0.4em; }
p { margin: 0.6em 0; }
b, strong { color: #fff; font-weight: 600; }
a { color: var(--h); }

.ct { color: var(--t); } .ch { color: var(--h); } .cm { color: var(--m); }

/* ---------------- nav ---------------- */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 26px;
  background: rgba(10, 15, 31, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
  font-family: "Sora", sans-serif; font-weight: 700; font-size: 1.02rem;
  color: var(--text); text-decoration: none; display: flex; align-items: center;
}
.brand .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 3px; }
.dot.t { background: var(--t); } .dot.h { background: var(--h); } .dot.m { background: var(--m); }
.navlinks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.navlinks a {
  color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 500;
  padding: 3px 2px; border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
}
.navlinks a:hover { color: #fff; }
.navlinks a.active { color: #fff; border-bottom-color: var(--h); }

/* ---------------- hero ---------------- */
.hero {
  position: relative; min-height: 96vh;
  display: grid; place-items: center;
  overflow: hidden;
}
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(10,15,31,0.15) 0%, rgba(10,15,31,0.35) 60%, var(--bg) 100%);
}
.hero-content { position: relative; z-index: 2; text-align: center; padding: 90px 24px 40px; max-width: 880px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.78rem; font-weight: 600;
  color: var(--accent, var(--h)); margin-bottom: 0.4em;
}
.hero-content .eyebrow { color: var(--h); }
.hero h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.9rem); font-weight: 700; margin: 0.15em 0 0.35em;
  background: linear-gradient(95deg, #ff9e64 5%, #f3f6fb 38%, #4cc9f0 70%, #54d68c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede {
  color: #c3cee0; font-size: clamp(1rem, 1.6vw, 1.18rem); max-width: 660px; margin: 0 auto 1.4em;
}
.hero-badges { display: flex; gap: 12px; justify-content: center; margin-bottom: 2em; flex-wrap: wrap; }
.badge {
  padding: 6px 16px; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  border: 1px solid; background: rgba(255,255,255,0.03);
}
.badge.bt { color: var(--t); border-color: rgba(255,158,100,0.45); }
.badge.bh { color: var(--h); border-color: rgba(76,201,240,0.45); }
.badge.bm { color: var(--m); border-color: rgba(84,214,140,0.45); }
.cta {
  display: inline-block; padding: 12px 28px; border-radius: 999px; text-decoration: none;
  font-weight: 600; color: #06121f; background: linear-gradient(95deg, #6fd6ff, #4cc9f0);
  box-shadow: 0 6px 28px rgba(76,201,240,0.35); transition: transform .2s, box-shadow .2s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 10px 34px rgba(76,201,240,0.5); }

/* ---------------- sections ---------------- */
section { max-width: 1100px; margin: 0 auto; padding: 84px 24px 10px; scroll-margin-top: 64px; }
.section-head { max-width: 820px; margin-bottom: 30px; }
.section-head .eyebrow { color: var(--accent); }
.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.25rem); margin: 0 0 0.4em;
  border-bottom: 3px solid var(--accent); display: inline-block; padding-bottom: 6px;
}
.intro { color: #c3cee0; font-size: 1.04rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.grid2.align-start { align-items: start; }
.mt { margin-top: 26px; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px 26px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
}
.card h3 .live {
  font-size: 0.66rem; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.12em;
  background: var(--accent); color: #07101e; border-radius: 5px; padding: 2.5px 7px; margin-right: 8px;
  font-family: "Inter", sans-serif; font-weight: 700;
}

.figure { width: 100%; height: auto; margin: 8px 0; }
.figure.narrow { max-width: 420px; display: block; margin: 14px auto 0; }

.eq { overflow-x: auto; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ---------------- demos ---------------- */
.demo-head p { color: var(--muted); font-size: 0.95rem; }
.demo-canvas {
  width: 100%; display: block; border-radius: 12px; margin-top: 12px;
  background: #0c1426; border: 1px solid rgba(255, 255, 255, 0.07);
}
.h280 { height: 280px; } .h330 { height: 330px; } .h340 { height: 340px; }
.h360 { height: 360px; } .h380 { height: 380px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 14px 26px; align-items: flex-end; margin-top: 16px;
}
.controls label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 0.84rem; color: var(--muted); font-weight: 500;
}
input[type="range"] { width: 190px; accent-color: var(--accent); cursor: pointer; }

.btn {
  font: 600 0.86rem "Inter", sans-serif; color: var(--accent);
  background: transparent; border: 1.5px solid var(--accent); border-radius: 999px;
  padding: 7px 18px; cursor: pointer; transition: background .2s, color .2s;
}
.btn:hover { background: var(--accent); color: #07101e; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: 600 0.84rem "Inter", sans-serif; color: var(--muted);
  background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
  border-radius: 999px; padding: 6px 15px; cursor: pointer; transition: all .2s;
}
.chip:hover { color: #fff; border-color: rgba(255,255,255,0.25); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #07101e; }

.readouts { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.readout {
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 9px 16px; min-width: 110px;
}
.ro-label { display: block; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; }
.ro-value { display: block; font-family: "Sora", sans-serif; font-weight: 600; font-size: 1.12rem; color: var(--accent); margin-top: 2px; }
.ro-value.small { font-size: 0.88rem; line-height: 1.3; }
.ro-value sup { font-size: 0.62em; }

.caption { font-size: 0.82rem; color: var(--muted); margin-top: 12px; }
.caption.center { text-align: center; }

/* phase bar (porosity demo) */
.phasebar {
  display: flex; height: 30px; border-radius: 8px; overflow: hidden; margin-top: 16px;
  border: 1px solid var(--panel-border); font-size: 0.75rem; font-weight: 600;
}
.pb-solid { background: #a98e62; color: #2a2113; display: flex; align-items: center; padding-left: 10px; transition: width .15s; }
.pb-pore  { background: #1f4e79; color: #bfe3ff; display: flex; align-items: center; padding-left: 10px; flex: 1; }

/* ---------------- coupling diagram ---------------- */
.coupling-wrap svg { width: 100%; height: auto; display: block; }
.coupling-wrap .arrow { transition: opacity .25s, stroke-width .15s; }
.coupling-wrap .hit { cursor: pointer; }
.coupling-wrap .node-g { cursor: pointer; }
.info-card { border-top: 4px solid var(--h); min-height: 220px; transition: border-color .3s; }
.info-card .examples { color: var(--muted); font-size: 0.9rem; font-style: italic; }
.loop-card { margin-top: 20px; border-left: 4px solid #b78bff; }
.loop-card p { font-size: 0.94rem; color: #c3cee0; }

/* ---------------- equations section ---------------- */
.eq-card h3 { margin-top: 1.2em; font-size: 1.05rem; }
.eq-card h3:first-child { margin-top: 0; }
.owner { font-size: 0.76rem; font-weight: 500; font-family: "Inter", sans-serif; margin-left: 8px; }
.legend-chips { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 18px; font-size: 0.86rem; color: var(--muted); }
.legend-chips .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

.symgrid {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 18px;
  font-size: 0.92rem; color: #c3cee0;
}
.symgrid > div:nth-child(odd) { color: var(--text); white-space: nowrap; }

/* ---------------- applications ---------------- */
.apps-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.card.app { padding-top: 18px; }
.appfig {
  width: 100%; height: auto; border-radius: 12px; display: block;
  background: #0c1426; border: 1px solid rgba(255,255,255,0.06); margin-bottom: 14px;
}
.card.app p { color: var(--muted); font-size: 0.94rem; }

/* ---------------- footer ---------------- */
footer { margin-top: 90px; border-top: 1px solid var(--panel-border); background: rgba(0,0,0,0.25); }
.foot-inner { max-width: 1100px; margin: 0 auto; padding: 48px 24px 56px; }
.refs { color: var(--muted); font-size: 0.9rem; padding-left: 20px; }
.refs li { margin: 6px 0; }
.fineprint { color: #5e6c84; font-size: 0.82rem; margin-top: 26px; }

/* ---------------- reveal animation ---------------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------------- responsive ---------------- */
@media (max-width: 920px) {
  .grid2, .apps-grid { grid-template-columns: 1fr; }
  .navlinks { display: none; }
  section { padding-top: 64px; }
}
