/* === Algorithm Visualisation Page — GiTrip colour scheme === */

/* Compact hero bar */
.algo-hero{
  background:radial-gradient(circle at top left,#2f4643,#1b251f);
  color:#fff;
  padding:18px 24px;
  text-align:center;
}
.algo-hero h1{
  font-size:22px;
  margin:0 0 4px;
  color:#fff;
}
.algo-hero .lead{
  font-size:13px;
  margin:0 auto;
  color:rgba(255,255,255,0.6);
  max-width:600px;
}

/* Main section — full width */
.algo-main{
  background:radial-gradient(ellipse at bottom,#233331,#1b251f);
  padding:20px 20px 60px;
}
.algo-main .card{
  background:rgba(47,70,67,0.6);
  border:1px solid rgba(255,255,255,0.1);
  color:#e8edec;
  border-radius:10px;
  padding:14px;
}

/* Grid: canvas + sidebar — full viewport width */
.algo-layout{
  display:grid;
  grid-template-columns:1fr 440px;
  gap:16px;
  align-items:start;
}

/* Map */
.algo-map-wrap{
  position:relative;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.08);
  overflow:hidden;
  aspect-ratio:16/10;
}
#algoMap{
  width:100%;
  height:100%;
}

/* Phase indicator */
.algo-phase{
  position:absolute;
  top:10px;
  left:10px;
  z-index:1000;
  padding:4px 12px;
  border-radius:999px;
  background:rgba(27,37,31,0.85);
  backdrop-filter:blur(4px);
  color:#ec5643;
  font-size:12px;
  font-weight:600;
  pointer-events:none;
  min-height:1em;
}

/* Stats overlay */
.algo-stats{
  position:absolute;
  bottom:12px;
  left:50%;
  z-index:1000;
  transform:translateX(-50%);
  padding:8px 20px;
  border-radius:10px;
  background:rgba(27,37,31,0.9);
  backdrop-filter:blur(6px);
  border:1px solid rgba(236,86,67,0.3);
  color:#ec5643;
  font-size:14px;
  font-weight:600;
  text-align:center;
  pointer-events:none;
  white-space:nowrap;
}

/* Sidebar */
.algo-sidebar{
  display:flex;
  flex-direction:column;
  gap:12px;
  position:sticky;
  top:60px;
}

/* Algorithm tabs */
.algo-tabs{
  display:flex;
  gap:2px;
}
.algo-tab{
  flex:1;
  padding:8px 10px;
  border:1px solid rgba(255,255,255,0.1);
  border-bottom:none;
  background:rgba(47,70,67,0.3);
  color:#8a9b97;
  font-size:12px;
  font-weight:600;
  border-radius:8px 8px 0 0;
  cursor:pointer;
  transition:background 0.2s,color 0.2s;
}
.algo-tab:hover{
  background:rgba(47,70,67,0.5);
  color:#e8edec;
}
.algo-tab.active{
  background:rgba(47,70,67,0.6);
  color:#ec5643;
  border-color:rgba(255,255,255,0.1);
}

/* Algorithm description */
.algo-description{
  margin:0;
  padding:8px 14px;
  font-size:12px;
  line-height:1.4;
  color:#8a9b97;
  background:rgba(47,70,67,0.6);
  border:1px solid rgba(255,255,255,0.1);
  border-top:none;
  border-radius:0 0 8px 8px;
}

/* Controls — single row */
.algo-controls-row{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}
.algo-controls .btn{
  min-width:auto;
  padding:6px 14px;
  font-size:13px;
}
.algo-controls .btn:disabled{
  opacity:0.4;
  cursor:not-allowed;
}
.algo-speed-label{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  color:#8a9b97;
  margin-left:auto;
}
.algo-speed-label input[type="range"]{
  width:100px;
  accent-color:#ec5643;
}
.algo-speed-value{
  min-width:28px;
  text-align:right;
}
.algo-start-label{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  color:#8a9b97;
}
.algo-start-label select{
  flex:1;
  background:#151f1d;
  color:#e8edec;
  border:1px solid rgba(255,255,255,0.15);
  border-radius:6px;
  padding:4px 8px;
  font-size:12px;
}

/* Pseudocode panel */
.algo-pseudocode-panel h2{
  margin:0 0 8px;
  font-size:14px;
  color:#ec5643;
}
.algo-code{
  background:#151f1d;
  border-radius:8px;
  padding:6px 8px;
  font-family:'SF Mono','Fira Code','Consolas',monospace;
  font-size:11px;
  line-height:1.1;
  overflow-x:auto;
  color:#8a9b97;
  margin:0;
  white-space:pre;
}
.algo-code .line{
  display:block;
  padding:0 4px;
  border-radius:3px;
  transition:background 0.3s ease,color 0.3s ease;
}
.algo-code .line.active{
  background:rgba(236,86,67,0.15);
  color:#ec5643;
}

/* Legend — horizontal row */
.algo-legend{
  padding:10px 14px;
}
.algo-legend-row{
  display:flex;
  gap:16px;
  flex-wrap:wrap;
}
.algo-legend-item{
  display:flex;
  align-items:center;
  gap:5px;
  font-size:12px;
  color:#8a9b97;
}
.algo-legend-swatch{
  width:10px;
  height:10px;
  border-radius:50%;
  flex-shrink:0;
}
.algo-legend-swatch--current{background:#ec5643;box-shadow:0 0 6px rgba(236,86,67,0.5)}
.algo-legend-swatch--visited{background:#5f7a74}
.algo-legend-swatch--unvisited{background:#4a9e8e}
.algo-legend-swatch--search{background:transparent;border:2px solid rgba(236,86,67,0.5)}

/* Map marker icons */
.algo-marker{
  display:flex;
  align-items:center;
  justify-content:center;
  width:28px;
  height:28px;
  border-radius:50%;
  font-size:11px;
  font-weight:700;
  color:#fff;
  border:2px solid #fff;
  box-shadow:0 2px 6px rgba(0,0,0,0.4);
  transition:transform 0.3s ease,box-shadow 0.3s ease;
}
.algo-marker--unvisited{background:#4a9e8e}
.algo-marker--current{background:#ec5643;transform:scale(1.3);box-shadow:0 0 14px rgba(236,86,67,0.6)}
.algo-marker--visited{background:#5f7a74}
.algo-marker--candidate{background:#f97316}

/* Leaflet tile desaturation for dark feel */
.algo-map-wrap .leaflet-tile-pane{
  filter:saturate(0.3) brightness(0.45);
}

/* Context / educational cards */
.algo-context{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr));
  gap:16px;
  margin-top:24px;
}
.algo-context-card{
  padding:20px;
}
.algo-context-card h3{
  color:#ec5643;
  margin:0 0 6px;
  font-size:15px;
}
.algo-context-card p{
  font-size:13px;
  line-height:1.5;
  color:#8a9b97;
  margin:0;
}

/* Responsive */
@media(max-width:960px){
  .algo-layout{
    grid-template-columns:1fr;
  }
  .algo-sidebar{
    position:static;
  }
}

/* Reduced motion */
@media(prefers-reduced-motion:reduce){
  .algo-map-wrap{display:none}
  .algo-controls{display:none}
  .algo-code .line{transition:none}
}

/* High contrast */
.high-contrast .algo-hero{background:#000}
.high-contrast .algo-main{background:#000}
.high-contrast .algo-main .card{background:#0f1418;border-color:#f97316}
.high-contrast .algo-code{background:#000;border:1px solid #f97316}
.high-contrast .algo-code .line.active{background:rgba(249,115,22,0.2);color:#f97316}
.high-contrast .algo-context-card h3{color:#f97316}
.high-contrast .algo-pseudocode-panel h2{color:#f97316}

/* --- Algorithm page mobile --- */
@media(max-width:768px){
  .algo-hero{ padding:14px 16px; }
  .algo-hero h1{ font-size:18px; }

  .algo-main{ padding:14px 12px 40px; }

  .algo-map-wrap{ aspect-ratio:4/3; }

  .algo-tab{
    padding:10px 8px;
    font-size:11px;
    min-height:44px;
  }

  .algo-controls .btn{
    min-height:44px;
    padding:8px 14px;
  }

  .algo-speed-label input[type="range"]{ width:80px; }

  .algo-code{ font-size:10px; padding:8px; }

  .algo-stats{
    white-space:normal;
    max-width:calc(100% - 24px);
    font-size:12px;
    padding:6px 14px;
  }

  .algo-context{
    grid-template-columns:1fr;
    gap:12px;
  }
}
