/* RANK-2 TENSOR MODULE - tensor-style.css */

/* --- RESET & VARIABLES ----------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background: #f5f0e8;
  color: #0e1117;
  line-height: 1.75;
  font-size: 18px;
}

/* --- WRAPPER --------------------------------------------- */
.tensor-module {
  max-width: 1200px;
  margin: 2rem auto;
  background: #fff;
  border: 1px solid #c8bfaf;
  box-shadow: 0 8px 40px rgba(14,17,23,0.12);
  border-radius: 2px;
  overflow: hidden;
}

/* --- HEADER ---------------------------------------------- */
.tm-header {
  background: #0e1117;
  color: #f5f0e8;
  padding: 2.8rem 3rem 2.2rem;
  position: relative;
  overflow: hidden;
}
.tm-header::before {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 30px, rgba(201,147,58,.04) 30px, rgba(201,147,58,.04) 31px),
    repeating-linear-gradient(-45deg, transparent, transparent 30px, rgba(201,147,58,.04) 30px, rgba(201,147,58,.04) 31px);
}
.tm-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #c9933a;
  margin-bottom: .6rem;
  position: relative;
}
.tm-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.9rem, 4vw, 2.9rem);
  font-weight: 700;
  line-height: 1.15;
  position: relative;
}
.tm-title em { font-style: italic; color: #e8b96a; }
.tm-subtitle {
  font-size: 1.05rem;
  color: #b0a898;
  margin-top: .7rem;
  font-style: italic;
  position: relative;
}
.tm-badge {
  display: inline-block;
  margin-top: 1.2rem;
  padding: .25rem .8rem;
  border: 1px solid #c9933a;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .65rem;
  letter-spacing: .12em;
  color: #c9933a;
  text-transform: uppercase;
  position: relative;
}

/* --- TAB NAV --------------------------------------------- */
.tm-tabs {
  display: flex;
  border-bottom: 2px solid #ede7d9;
  background: #f5f0e8;
  position: sticky;
  top: 0;
  z-index: 100;
}
.tm-tab {
  flex: 1;
  padding: 1rem .5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #6b6457;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.tm-tab .tab-icon { font-size: 1rem; }
.tm-tab:hover { color: #0e1117; background: #ede7d9; }
.tm-tab.active {
  color: #1a6b72;
  border-bottom-color: #1a6b72;
  background: #fff;
  font-weight: 600;
}

/* --- PANELS ---------------------------------------------- */
.tm-panel { display: none; padding: 2.8rem 3rem 3rem; }
.tm-panel.active { display: block; animation: fadeUp .35s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- DEMO PANEL ------------------------------------------ */
.demo-frame-wrap {
  background: #0e1117;
  border-radius: 4px;
  overflow: visible;
  box-shadow: 0 4px 24px rgba(14,17,23,0.12);
  margin-bottom: 1.5rem;
  position: relative;
  width: 100%;
  /*
    Aspect ratio derived from GeoGebra coordinate bounds:
    X: -19 to +16 = 35 units wide
    Y:  -8 to +16 = 24 units tall
    Ratio: 24/35 = 68.57%  - shows the FULL coordinate window
  */
  height: 0;
  padding-bottom: 68.57%;
}
.demo-frame-label {
  position: absolute;
  top: .6rem; left: .8rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .6rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: #c9933a;
  opacity: .8;
  z-index: 10;
  pointer-events: none;
}
.demo-frame-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Cap max height on very wide screens so it doesn't get too tall */
@media (min-width: 1400px) {
  .demo-frame-wrap {
    height: 780px;
    padding-bottom: 0;
  }
}
/* Responsive height adjustments */
@media (max-width: 768px)  { .demo-frame-wrap { padding-bottom: 75%; } }
@media (max-width: 480px)  { .demo-frame-wrap { padding-bottom: 85%; } }
.demo-placeholder {
  width: 100%;
  height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #131820;
  color: #4a5260;
  gap: 1rem;
}
.demo-placeholder p {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.demo-controls-info {
  background: #ede7d9;
  border-left: 3px solid #c9933a;
  padding: 1rem 1.4rem;
  border-radius: 0 3px 3px 0;
  font-size: .92rem;
  margin-top: 1rem;
}
.demo-controls-info strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #c9933a;
  display: block;
  margin-bottom: .5rem;
}
.demo-controls-info ul { padding-left: 1.2rem; }
.demo-controls-info li { margin-bottom: .3rem; color: #6b6457; font-size: .9rem; }
.demo-controls-info li span {
  font-family: 'JetBrains Mono', monospace;
  font-size: .8rem;
  color: #1a6b72;
  font-weight: 600;
}

/* --- THEORY SECTIONS ------------------------------------- */
.theory-section { margin-bottom: 2.5rem; }

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: #1a6b72;
  display: block;
  margin-bottom: .25rem;
}
.section-heading {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0e1117;
  margin-bottom: .8rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid #c9933a;
  display: inline-block;
}
.sub-heading {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  margin: 2rem 0 .8rem;
}
p + p { margin-top: .9rem; }

/* --- CAR ANALOGY BOX ------------------------------------- */
.analogy-box {
  background: linear-gradient(135deg, #0e1117 0%, #1a2535 100%);
  color: #f5f0e8;
  border-radius: 4px;
  padding: 2rem 2.2rem;
  margin: 1.8rem 0;
  position: relative;
  overflow: hidden;
}
.analogy-box::before {
  content: '';
  position: absolute;
  right: 1.5rem; top: 1rem;
  font-size: 3.5rem;
  opacity: .12;
}
.analogy-box .analogy-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: #c9933a;
  margin-bottom: .8rem;
  display: block;
}
.analogy-box h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  margin-bottom: .8rem;
  color: #fff;
}
.analogy-box p { font-size: .95rem; color: #bbb; line-height: 1.7; }
.analogy-box p + p { margin-top: .7rem; }
.analogy-box strong { color: #e8b96a; }

/* --- MATH BLOCK ------------------------------------------ */
.math-block {
  background: #0e1117;
  color: #d4f1d4;
  font-family: 'JetBrains Mono', monospace;
  font-size: .88rem;
  padding: 1.4rem 1.8rem;
  border-radius: 3px;
  margin: 1.4rem 0;
  overflow-x: auto;
  line-height: 2.1;
  border-left: 3px solid #1a6b72;
}
.math-block .comment { color: #e8b96a; font-size: .78rem; }
.math-block .hl      { color: #e8b96a; font-weight: 600; }
.math-block .res     { color: #e8b96a; }

.mono-inline {
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  color: #1a6b72;
  background: #f0fafa;
  padding: .05rem .35rem;
  border-radius: 2px;
  border: 1px solid #d0eaec;
}

/* --- CALLOUTS -------------------------------------------- */
.callout {
  border-left: 3px solid #1a6b72;
  background: #f0f8f9;
  padding: 1rem 1.4rem;
  margin: 1.4rem 0;
  border-radius: 0 3px 3px 0;
}
.callout.gold { border-left-color: #c9933a; background: #fdf8f0; }
.callout.red  { border-left-color: #8b2e2e;  background: #fdf0f0; }
.callout strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  display: block;
  margin-bottom: .3rem;
  color: #1a6b72;
}
.callout.gold strong { color: #c9933a; }
.callout.red  strong { color: #8b2e2e; }
.callout p { font-size: .92rem; color: #6b6457; }

/* --- MATRIX VISUAL --------------------------------------- */
.matrix-wrap {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin: 1.2rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: .85rem;
}
.matrix {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .2rem .6rem;
  background: #ede7d9;
  border: 1px solid #c8bfaf;
  border-radius: 3px;
  padding: .8rem 1.2rem;
  position: relative;
}
.matrix::before, .matrix::after {
  content: '';
  position: absolute;
  top: 4px; bottom: 4px;
  width: 3px;
  background: #0e1117;
  border-radius: 1px;
}
.matrix::before { left: 4px; }
.matrix::after  { right: 4px; }
.matrix span { text-align: center; padding: .1rem .2rem; }
.matrix span.val { color: #1a6b72; font-weight: 600; }
.matrix-label { font-size: .7rem; text-align: center; color: #6b6457; margin-top: .3rem; }
.matrix-eq { font-size: 1.1rem; color: #6b6457; align-self: center; }

/* --- WORKED EXAMPLE -------------------------------------- */
.worked-example {
  background: #f5f0e8;
  border: 1px solid #c8bfaf;
  border-radius: 4px;
  padding: 1.6rem 1.8rem;
  margin: 1.6rem 0;
}
.we-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}
.we-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: #fff;
  background: #1a6b72;
  padding: .2rem .65rem;
  border-radius: 2px;
  white-space: nowrap;
}
.we-header h4 { font-family: 'Playfair Display', serif; font-size: 1rem; }
.step-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .5rem 1rem;
  align-items: start;
  margin-bottom: .7rem;
  font-size: .92rem;
}
.sl-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  color: #c9933a;
  background: #fdf8f0;
  border: 1px solid #c9933a;
  border-radius: 50%;
  width: 1.5rem; height: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: .15rem;
}
.sl-text { color: #6b6457; line-height: 1.6; }

/* --- REAL-LIFE CARDS ------------------------------------- */
.reallife-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
  margin: 1.5rem 0;
}
.rl-card {
  background: #0e1117;
  color: #f5f0e8;
  border-radius: 4px;
  padding: 1.4rem 1.2rem;
  position: relative;
  overflow: hidden;
  transition: transform .2s;
}
.rl-card:hover { transform: translateY(-3px); }
.rl-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: #c9933a;
}
.rl-icon { font-size: 1.8rem; margin-bottom: .7rem; }
.rl-card h4 {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: #e8b96a;
  margin-bottom: .5rem;
}
.rl-card p { font-size: .85rem; color: #9a9490; line-height: 1.6; }

/* --- HOW TO USE PANEL ------------------------------------ */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.4rem;
  margin: 1.8rem 0;
}
.step-card {
  background: #f5f0e8;
  border: 1px solid #c8bfaf;
  border-radius: 3px;
  padding: 1.4rem 1.2rem;
  transition: box-shadow .2s;
}
.step-card:hover { box-shadow: 0 4px 16px rgba(14,17,23,0.12); }
.step-num {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: #c9933a;
  line-height: 1;
  margin-bottom: .4rem;
}
.step-card h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #1a6b72;
  margin-bottom: .4rem;
}
.step-card p { font-size: .9rem; color: #6b6457; line-height: 1.6; }

/* --- PARAMETER TABLE ------------------------------------- */
.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin: 1rem 0 1.5rem;
}
.param-table th {
  background: #0e1117;
  color: #c9933a;
  font-family: 'JetBrains Mono', monospace;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: .6rem 1rem;
  text-align: left;
}
.param-table td {
  padding: .6rem 1rem;
  border-bottom: 1px solid #ede7d9;
  vertical-align: top;
  color: #6b6457;
}
.param-table tr:nth-child(even) td { background: #f5f0e8; }
.param-table td:first-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  color: #1a6b72;
  font-weight: 600;
}

/* --- FOOTER ---------------------------------------------- */
.tm-footer {
  background: #f5f0e8;
  border-top: 1px solid #c8bfaf;
  padding: 1rem 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.tm-footer span {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6b6457;
}
.tm-footer a {
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #1a6b72;
  text-decoration: none;
}
.tm-footer a:hover { text-decoration: underline; }

/* --- RESPONSIVE ------------------------------------------ */
@media (max-width: 640px) {
  .tm-header { padding: 1.8rem 1.2rem 1.4rem; }
  .tm-panel  { padding: 1.6rem 1.2rem 2rem; }
  .tm-footer { padding: .8rem 1.2rem; }
  .tm-tab .tab-text { display: none; }
  .tm-tab .tab-icon { font-size: 1.3rem; }
  .tm-tab { padding: .9rem .3rem; }
  .matrix-wrap { gap: .6rem; }
}
