/* ============================================================
   Rainwater Tutoring — Math Tools Design System
   Matches Assessment v2: PP Editorial Old + Inter
   Editorial Luxe Aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #fdfcfa;
  --srf: #ffffff;
  --elevated: #f7f5f1;
  --tx: #2c2c2c;
  --tx2: #5a5a5a;
  --tx3: #8a8a8a;
  --bd: #ddd9d0;
  --bdl: #eae7e1;
  --acc: #2d5a3d;
  --acc2: #3A8F85;
  --warm: #f7f5f1;
  --serif: 'PP Editorial Old', 'Didot', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* v2 semantic colors */
  --success: #2d5a3d;
  --success-bg: rgba(45, 90, 61, 0.08);
  --error: #b5503a;
  --error-bg: rgba(181, 80, 58, 0.08);
  --warning: #c09530;
  --warning-bg: rgba(192, 149, 48, 0.08);
}

/* PP Editorial Old — load from assessment-v2 fonts if available */
@font-face {
  font-family: 'PP Editorial Old';
  src: url('/fonts/PPEditorialOld-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'PP Editorial Old';
  src: url('/fonts/PPEditorialOld-Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'PP Editorial Old';
  src: url('/fonts/PPEditorialOld-Ultralight.otf') format('opentype');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'PP Editorial Old';
  src: url('/fonts/PPEditorialOld-UltralightItalic.otf') format('opentype');
  font-weight: 200;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'PP Editorial Old';
  src: url('/fonts/PPEditorialOld-Ultrabold.otf') format('opentype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--tx);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
  overflow: hidden;
}

/* ======================== FOCUS MODE ======================== */
body.focus-mode {
  font-size: 16px;
  line-height: 1.7;
}
body.focus-mode .rt-latex { font-size: 26px !important; }
body.focus-mode .rt-result-val { font-size: 18px !important; }
body.focus-mode .rt-input { font-size: 18px !important; }

/* ======================== ANIMATIONS ======================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

.anim-fade { animation: fadeIn 0.35s var(--ease) both; }
.anim-slide { animation: slideIn 0.3s var(--ease) both; }

/* ======================== NAV ======================== */
.rt-nav {
  height: 48px;
  background: var(--srf);
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.rt-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--tx3);
  transition: color 0.2s var(--ease);
}
.rt-brand:hover { color: var(--tx2); }

.rt-brand-mark {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 11px;
  color: var(--tx3);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.rt-brand-sub {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 400;
  font-style: italic;
  color: var(--tx2);
}

.rt-sep {
  width: 1px;
  height: 18px;
  background: var(--bd);
  flex-shrink: 0;
}

.rt-nav-right {
  margin-left: auto;
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

/* ======================== TOOL SWITCHER ======================== */
.rt-tool-switcher {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--elevated);
  border-radius: 8px;
  padding: 3px;
  gap: 1px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 1;
  min-width: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.rt-tool-switcher::-webkit-scrollbar { display: none; }

.rt-tool-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--tx3);
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  position: relative;
  z-index: 2;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
  cursor: pointer;
}
.rt-tool-tab:hover { color: var(--tx); background: rgba(0,0,0,0.04); }
.rt-tool-tab.active { color: var(--tx); font-weight: 600; background: var(--srf); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.rt-slider {
  position: absolute;
  top: 3px;
  height: calc(100% - 6px);
  background: var(--srf);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  z-index: 1;
  transition: left 0.25s var(--ease), width 0.25s var(--ease);
  opacity: 0;
  pointer-events: none;
}

/* ======================== BUTTONS ======================== */
.rt-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bd);
  background: var(--srf);
  font-size: 12px;
  font-weight: 500;
  color: var(--tx2);
  cursor: pointer;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.rt-btn:hover { background: var(--warm); border-color: var(--bd); transform: translateY(-1px); }
.rt-btn:active { transform: translateY(0); }
.rt-btn.on { background: var(--acc); color: #fff; border-color: var(--acc); }

.rt-btn-focus {
  background: var(--warm);
  border-color: var(--bd);
  color: var(--tx2);
  font-weight: 600;
}
.rt-btn-focus.on { background: var(--acc); color: #fff; border-color: var(--acc); }

/* ======================== PILLS / TABS ======================== */
.rt-pills {
  display: inline-flex;
  background: var(--elevated);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.rt-pill {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--tx3);
  font-family: var(--sans);
  transition: all 0.2s var(--ease);
}
.rt-pill.on { background: var(--srf); color: var(--tx); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.rt-pill:hover:not(.on) { color: var(--tx2); }

/* ======================== INPUTS ======================== */
.rt-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--tx);
  background: var(--srf);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.rt-input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(45,90,61,0.08); }
.rt-input::placeholder { color: #bbb; }

.rt-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warm);
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: all 0.2s var(--ease);
}
.rt-input-group:focus-within { border-color: var(--acc); background: var(--srf); box-shadow: 0 0 0 3px rgba(45,90,61,0.08); }
.rt-input-group label {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  color: var(--tx3);
  flex-shrink: 0;
  user-select: none;
}
.rt-input-group input {
  flex: 1; border: none; outline: none;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--tx);
  background: transparent;
  padding: 10px 0;
}
.rt-input-group input::placeholder { color: #bbb; }

/* ======================== LATEX DISPLAY ======================== */
.rt-latex {
  font-size: 20px;
  min-height: 30px;
  display: flex;
  align-items: center;
  color: var(--tx);
  line-height: 1.4;
}
.rt-latex.placeholder {
  color: var(--tx3);
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
}

/* ======================== RESULTS ======================== */
.rt-section-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 0 6px;
  border-bottom: 1px solid var(--bdl);
  margin-bottom: 4px;
}

.rt-result {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  animation: fadeIn 0.25s var(--ease) both;
}

.rt-result-tag {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--sans);
}

.rt-result-val {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--tx);
}

.rt-result.info    { background: var(--elevated); }
.rt-result.info    .rt-result-tag { background: var(--bdl); color: var(--tx2); }
.rt-result.hole    { background: rgba(192,149,48,0.06); }
.rt-result.hole    .rt-result-tag { background: rgba(192,149,48,0.12); color: #8a6e1a; }
.rt-result.va      { background: rgba(181,80,58,0.06); }
.rt-result.va      .rt-result-tag { background: rgba(181,80,58,0.12); color: var(--error); }
.rt-result.ha      { background: rgba(58,143,133,0.06); }
.rt-result.ha      .rt-result-tag { background: rgba(58,143,133,0.12); color: #2a7a70; }
.rt-result.oa      { background: rgba(100,70,160,0.06); }
.rt-result.oa      .rt-result-tag { background: rgba(100,70,160,0.12); color: #5a40a0; }
.rt-result.dom     { background: rgba(45,90,61,0.06); }
.rt-result.dom     .rt-result-tag { background: rgba(45,90,61,0.12); color: var(--acc); }
.rt-result.parent  { background: rgba(100,70,160,0.06); }
.rt-result.parent  .rt-result-tag { background: rgba(100,70,160,0.12); color: #5a40a0; }
.rt-result.trans   { background: rgba(45,90,61,0.06); }
.rt-result.trans   .rt-result-tag { background: rgba(45,90,61,0.12); color: var(--acc); }

/* ======================== STEP BOXES ======================== */
.rt-step {
  background: var(--warm);
  border-left: 3px solid var(--acc);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--tx2);
  animation: slideIn 0.3s var(--ease) both;
}
body.focus-mode .rt-step { font-size: 15px; padding: 14px 18px; }

.rt-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: var(--acc);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  margin-right: 8px;
  flex-shrink: 0;
}

/* ======================== GRAPH ======================== */
.rt-graph-wrap {
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  background: var(--srf);
}
.rt-graph-wrap canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
.rt-coord-badge {
  position: absolute;
  bottom: 10px; left: 10px;
  background: rgba(253,252,250,0.95);
  border: 1px solid var(--bd);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tx2);
  pointer-events: none;
  display: none;
  backdrop-filter: blur(4px);
}
.rt-graph-toolbar {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 10;
}
.rt-graph-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bd);
  background: rgba(253,252,250,0.95);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--tx2);
  font-size: 16px;
  transition: all 0.15s var(--ease);
  backdrop-filter: blur(4px);
}
.rt-graph-btn:hover { background: var(--srf); border-color: #aaa; transform: scale(1.05); }

/* ======================== PANELS ======================== */
.rt-panel {
  background: var(--srf);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  overflow: hidden;
}
.rt-panel-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--bdl);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.rt-panel-body { padding: 16px; }

/* ======================== TOOL LAYOUT ======================== */
.rt-tool-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 48px);
}
.rt-tool-layout > .rt-tool-input {
  padding: 28px;
  overflow-y: auto;
  border-right: 1px solid var(--bd);
  background: var(--srf);
}
.rt-tool-layout > .rt-tool-output {
  padding: 28px;
  overflow-y: auto;
  background: var(--bg);
}

@media (max-width: 800px) {
  .rt-tool-layout { grid-template-columns: 1fr; height: auto; }
  .rt-tool-layout > .rt-tool-input { border-right: none; border-bottom: 1px solid var(--bd); }
}

/* ======================== PAGE TITLES ======================== */
.rt-page-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--tx);
  letter-spacing: -0.5px;
  line-height: 1.15;
  margin-bottom: 4px;
}
body.focus-mode .rt-page-title { font-size: 34px; }

.rt-page-subtitle {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--tx3);
  margin-bottom: 16px;
}

/* ======================== SCROLLBAR ======================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc8c0; border-radius: 2px; }

/* ======================== UTILITY ======================== */
.rt-muted { color: var(--tx3); }
.rt-serif { font-family: var(--serif); }
.rt-mono { font-family: var(--mono); }
.rt-gap-8 { gap: 8px; }
.rt-gap-12 { gap: 12px; }
.rt-mb-8 { margin-bottom: 8px; }
.rt-mb-16 { margin-bottom: 16px; }
