/* Trailbaker — the Trail Lab workspace. */

.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 1.5rem;
  align-items: start;
  padding: 1.5rem 0 2rem;
}

/* --- the map --- */

.map-stack {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--bg-sunken);
  box-shadow: var(--shadow);
}
.map-stack canvas,
.map-stack svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-stack svg { touch-action: none; }

#trailSvg[data-mode="draw"]    { cursor: crosshair; }
#trailSvg[data-mode="erase"]   { cursor: not-allowed; }
#trailSvg[data-mode="feature"] { cursor: copy; }

.handle { cursor: grab; }
.handle:active { cursor: grabbing; }
.feature-marker { cursor: pointer; }
#trailSvg :focus-visible { outline: 2.5px solid var(--accent); outline-offset: 1px; }

.map-legend {
  display: flex; flex-wrap: wrap; gap: .25rem 1.1rem;
  margin: .7rem 0 0; padding: 0; list-style: none;
  font-size: .8rem; color: var(--ink-soft);
}
.map-legend li { display: flex; align-items: center; gap: .4rem; }
.map-legend .swatch { width: 15px; height: 4px; border-radius: 2px; flex: none; }

/* --- the hint strip --- */

.hint {
  min-height: 1.5rem; margin: .55rem 0 0;
  font-size: .88rem; color: var(--ink-soft);
  opacity: 0; transition: opacity .18s;
}
.hint.is-on { opacity: 1; }

/* --- toolbars --- */

.toolbar {
  display: flex; flex-wrap: wrap; gap: .45rem; align-items: center;
  margin-top: .9rem;
}
.toolbar + .toolbar { margin-top: .55rem; }
.toolbar .sep {
  width: 1px; align-self: stretch; background: var(--rule); margin: .1rem .35rem;
}
.toolbar .btn { padding: .48rem .8rem; font-size: .87rem; }

.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; font-size: .82rem; font-weight: 600;
  padding: .32rem .6rem .32rem .34rem;
  border: 1px solid var(--rule); border-radius: 999px;
  background: var(--bg-raised); color: var(--ink-soft); cursor: pointer;
}
.chip:hover { background: var(--bg-sunken); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: transparent; color: var(--accent-ink);
}
.chip[aria-pressed="true"] .chip-abbr { background: rgba(255,255,255,.25); color: inherit; }
.chip-abbr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: .66rem; font-weight: 800; letter-spacing: -.02em;
  background: var(--bg-sunken); color: var(--ink);
}
.chip-abbr[data-rating="0"] { box-shadow: inset 0 0 0 2px var(--green); }
.chip-abbr[data-rating="1"] { box-shadow: inset 0 0 0 2px var(--blue); }
.chip-abbr[data-rating="2"] { box-shadow: inset 0 0 0 2px var(--black); }
.chip-abbr[data-rating="3"] { box-shadow: inset 0 0 0 2px var(--dblack); }

/* --- profile --- */

.profile-wrap {
  margin-top: 1rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--bg-raised); padding: .5rem .25rem .25rem;
}
.profile-wrap h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); margin: 0 0 .1rem .75rem;
}
#profileSvg { width: 100%; height: auto; display: block; touch-action: none; }

/* --- side panel --- */

.lab-panel { position: sticky; top: 76px; display: grid; gap: 1rem; }

.score { background: var(--bg-raised); border: 1px solid var(--rule);
         border-radius: var(--radius-lg); padding: 1rem 1.1rem; }
.score-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.score-head h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
                 color: var(--ink-faint); margin: 0; }

.stats { display: grid; grid-template-columns: 1fr; gap: 0; margin: .9rem 0 0; }
.stats > div { display: flex; justify-content: space-between; align-items: baseline;
               gap: .5rem; padding: .3rem 0; border-bottom: 1px dotted var(--rule); }
.stats dt { font-size: .8rem; color: var(--ink-soft); }
.stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }

.coach { display: grid; gap: .6rem; }
.tip {
  border: 1px solid var(--rule); border-left: 3px solid var(--ink-faint);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-raised); padding: .7rem .85rem;
}
.tip h4 { margin: 0 0 .25rem; font-size: .88rem; }
.tip p  { margin: 0; font-size: .84rem; color: var(--ink-soft); line-height: 1.5; }
.tip-good { border-left-color: var(--green); }
.tip-warn { border-left-color: var(--warn); }
.tip-bad  { border-left-color: var(--bad); }
.tip.is-locatable { cursor: pointer; }
.tip.is-locatable:hover { background: var(--bg-sunken); }

@media (max-width: 960px) {
  .lab { grid-template-columns: minmax(0, 1fr); }
  .lab-panel { position: static; }
  .stats { grid-template-columns: 1fr 1fr; gap: .1rem 1.4rem; }
}
@media (max-width: 480px) {
  .toolbar .btn { padding: .55rem .7rem; }
  .stats { grid-template-columns: 1fr; }
}
