/* Trace page styles. The design system (tokens, fonts, .panel, .btn, .badge …) comes from
   ../shared/jw/bundle.css; this file only adds what Trace needs. */

/* The hidden attribute always wins over layout rules like .row { display: flex }. */
[hidden]{ display: none !important; }

*{ box-sizing: border-box; }
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family: var(--serif); line-height:1.5;
  padding: 40px 20px 80px;
}
.wrap{ max-width: 1080px; margin: 0 auto; }

header{ margin-bottom: 28px; }
.header-top{ display:flex; justify-content:space-between; align-items:center; gap: 12px; flex-wrap: wrap; }
.header-top .jw-controls{ flex-wrap: wrap; }
header .kicker{ font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: 0.02em; }
header .kicker a{ color: inherit; text-decoration: none; }
header .kicker a:hover{ text-decoration: underline; }
h1{ font-family: var(--font-display); font-weight: 600; font-size: 32px; margin: 6px 0 8px; color: var(--text); }
header p{ color: var(--dim); max-width: 66ch; font-size: 15px; }

.panel{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.panel h2{
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--accent); margin: 0;
}
.panel-header{
  display:flex; justify-content:space-between; align-items:center;
  user-select: none; margin-bottom: 14px;
}
/* The collapse button itself (.collapse-icon) and the header's pointer come from bundle.css. */
.collapse-icon{ flex-shrink: 0; }
.header-controls{ display:flex; align-items:center; gap: 8px; flex-shrink: 0; }
/* The value-labels toggle is a design system chip (.btn.chip, shared/jw/bundle.css). */
.value-labels-toggle{ white-space: nowrap; line-height: 1; }
.value-labels-toggle:hover{ color: var(--text); border-color: var(--accent-dim); }
.panel.collapsed .value-labels-toggle{ display: none; }
.panel.collapsed .panel-header{ margin-bottom: 0; }
.panel h3{
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--dim); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.panel h3:first-of-type{ margin-top: 0; }

/* Keep the player's name at the left of its panel header, ahead of the
   Beanstalk girder stripe that the design system inserts there. */
.panel .panel-header > .player-head{ order: 0; margin-right: auto; }
.player-name{
  font-family: var(--font-display); font-weight: 600; font-size: 21px;
  color: var(--text); margin: 0 0 4px;
}
.player-sub{ font-family: var(--mono); font-size: 11.5px; color: var(--dim); margin-bottom: 14px; }

textarea{
  width: 100%; min-height: 220px; resize: vertical;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  font-family: var(--mono); font-size: 12.5px; padding: 12px;
}
textarea:focus{ outline: none; border-color: var(--accent-dim); }

.row{ display:flex; gap:10px; margin-top: 14px; flex-wrap: wrap; align-items:center; }

/* Buttons are .btn / .btn.secondary from the design system (shared/jw/bundle.css). */
.btn:disabled{ cursor: default; opacity: 0.6; }

a.bookmarklet-link{
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  cursor: grab; text-decoration: none;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 18px; border-radius: var(--radius-md);
  box-shadow: var(--glow); transition: filter 0.15s;
}
a.bookmarklet-link:active{ cursor: grabbing; }
a.bookmarklet-link:hover{ filter: brightness(1.15); }

.status{ font-family: var(--mono); font-size: 12.5px; color: var(--dim); }

label.toggle{
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
label.toggle input{ accent-color: var(--accent); }
label.toggle:hover{ color: var(--text); }

.summary-grid{
  display:grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap: 14px; margin-bottom: 16px;
}
.stat{ border-left: 2px solid var(--accent-dim); padding: 4px 0 4px 12px; }
.stat .num{ font-family: var(--mono); font-size: 24px; color: var(--accent); display:block; }
.stat .label{ font-family: var(--mono); font-size: 11.5px; color: var(--dim); }

.badges-row{ display:flex; gap: 24px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.player-badges{ font-family: var(--mono); font-size: 12.5px; display:flex; align-items:center; gap: 8px; }
/* .badge, .badge.corp/.runner and .badge.achievement come from shared/jw/bundle.css. */
.player-badges{ flex-wrap: wrap; }
.player-badges .badge-player.corp, .stat .num.corp{ color: var(--corp); }
.player-badges .badge-player.runner, .stat .num.runner{ color: var(--runner); }
.stat.corp{ border-left-color: var(--corp); }
.stat.runner{ border-left-color: var(--runner); }

.badge[data-desc]{ position: relative; cursor: help; }
.badge[data-desc]::after{
  content: attr(data-desc);
  position: absolute; left: 0; bottom: calc(100% + 6px);
  width: max-content; max-width: 240px; white-space: normal; text-align: center;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-md); padding: 6px 9px;
  font-weight: 400; letter-spacing: 0; line-height: 1.35;
  opacity: 0; visibility: hidden; pointer-events: none; z-index: 20;
  transition: opacity 0.12s ease;
}
.badge[data-desc]:hover::after, .badge[data-desc]:focus::after{ opacity: 1; visibility: visible; }

table{ width:100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 6px; }
th, td{ text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th{
  font-family: var(--mono); font-size: 11px; color: var(--dim);
  font-weight: 500; cursor: pointer; user-select:none; white-space: nowrap;
}
th:hover{ color: var(--accent); }
/* Sortable headers are buttons so they work from the keyboard; they look like the header text. */
.th-sort{ background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit; }
.th-sort:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }
/* Text for screen readers only. */
.visually-hidden{ position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
th.sorted::after{ content: " \2193"; color: var(--accent); }
th.sorted-asc::after{ content: " \2191"; color: var(--accent); }
td.num, th.num{ text-align:right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.card{ font-weight: 600; }
.instance-tag{ font-weight: 400; font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
td.neg{ color: var(--neg); }
td.pos{ color: var(--pos); }
tr:hover td{ background: var(--panel-2); }
.empty-note{ color: var(--dim); font-size: 13px; font-family: var(--mono); padding: 8px 0 14px; }

.table-actions{ display:flex; justify-content: space-between; align-items:center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.table-actions h3{ margin: 0; }
.table-actions .controls{ display:flex; align-items:center; gap: 12px; }

.mini-table{ margin-bottom: 4px; }

/* Wide tables scroll sideways inside their own box instead of stretching the page. */
.table-scroll{ overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; margin-bottom: 6px; }
.table-scroll > table{ margin-bottom: 0; }

@media (max-width: 640px){
  body{ padding: 24px 10px 60px; }
  .panel{ padding: 14px 12px; }
  /* Console light's title bar runs edge to edge by undoing the panel's
     desktop padding; match the smaller phone padding instead. */
  [data-theme="console-light"] .panel-header{ margin: -14px -12px 14px; padding: 6px 12px; }
  table{ font-size: 12.5px; }
  th, td{ padding: 6px 7px; }
  .table-actions .controls{ flex-wrap: wrap; }
}

details{ margin-top: 4px; }
summary{
  font-family: var(--mono); font-size: 12.5px; color: var(--dim);
  cursor: pointer; padding: 4px 0;
}
summary:hover{ color: var(--text); }
.flag-line{
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.flag-line .reason{ color: var(--warn); }

.caveats{ font-size: 13px; color: var(--dim); }
.caveats li{ margin-bottom: 6px; }

.legend{ margin-bottom: 10px; }

footer{ text-align:center; color: var(--dim); font-family: var(--mono); font-size: 11.5px; margin-top: 40px; }
/* Underlined so the links don't rely on colour alone. */
footer a{ color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* Reserves space for #results while a shared log is being decoded/parsed
   from the URL hash, so revealing it doesn't produce a large, late layout
   shift (this matters even though the overlay below hides it visually —
   the CLS measurement doesn't care what's occluding what). */
#results.loading{ min-height: 640px; }

/* Full-page loading screen shown, as early as possible, while a shared
   log from the URL hash is being decoded and parsed. Covers the normal
   "paste a log" shell so visitors following a share/bookmarklet link see
   one loading screen and then the finished result, not a flash of the
   empty form followed by content popping in underneath it. */
#hashLoadOverlay{
  display:none; position:fixed; inset:0; z-index:1000; background:var(--bg);
  align-items:center; justify-content:center; flex-direction:column; gap:14px;
  color:var(--dim); font-family:var(--mono); font-size:14px;
}
.spinner-ring{
  width:28px; height:28px; border:2px solid var(--line); border-top-color: var(--accent);
  border-radius:50%; animation: spin 0.8s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* Classes that replace the page's former style attributes (the CSP forbids those). */
.panel-note{ color: var(--dim); font-size: 13.5px; margin: 0 0 14px; }
.row.flush{ margin-top: 0; }
.status.status-block{ display: block; margin-top: 10px; }
.status.error{ color: var(--neg); }
.steps{ color: var(--dim); font-size: 13.5px; padding-left: 18px; margin: 0; }
.steps li:not(:last-child){ margin-bottom: 8px; }
.steps strong{ color: var(--text); }
#permalinkUrlInput{
  flex: 1; min-width: 200px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-md);
  font-family: var(--mono); font-size: 11.5px; padding: 8px;
}
.stat.stat-total{ margin-bottom: 16px; }
details.chart-table{ margin-top: 10px; }
.chart-note{ font-size: 12.5px; color: var(--dim); margin: -6px 0 12px; }
.chart-svg{ width: 100%; height: auto; font-family: var(--mono); }
.badge.concede{ border-color: var(--neg); color: var(--neg); }
.no-chat{ color: var(--dim); }
/* Detail rows under a card: the first cell is indented and dimmed. */
tr.sub-row{ background: var(--panel-2); }
tr.sub-row td:first-child{ padding-left: 28px; color: var(--dim); }
