/* viewer.css — styles for the FMDL viewer. */

/* Layout: one-screen tool. Team roster on the left (when an export is open), viewport in the middle,
   model details on the right; everything stacks under the viewport on phones. */

:root {
  --bg: #eef0ee;
  --panel: #f8f9f7;
  --line: #d3d8d2;
  --fg: #1d2420;
  --muted: #5d6a62;
  --accent: #1f8a4c;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe3;
  --viewport: #dfe4df;
  --warn: #a1610b;
  --display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614;
    --panel: #181d1a;
    --line: #2b332e;
    --fg: #e3e9e4;
    --muted: #8e9b93;
    --accent: #3fbf73;
    --accent-ink: #08130c;
    --accent-soft: #1b3324;
    --viewport: #0d100e;
    --warn: #e0a24a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121614;
  --panel: #181d1a;
  --line: #2b332e;
  --fg: #e3e9e4;
  --muted: #8e9b93;
  --accent: #3fbf73;
  --accent-ink: #08130c;
  --accent-soft: #1b3324;
  --viewport: #0d100e;
  --warn: #e0a24a;
  color-scheme: dark;
}

html, body {
  height: 100%;
}

[hidden] {
  display: none !important;
}

/* Control hints (keys for players, kits and the view) can be turned off in the settings. */
body.no-hints .control-hint {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 var(--body);
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: relative;
  z-index: 2;
}

button.icon {
  display: grid;
  place-items: center;
  padding: 6px 8px;
}

#captureButton {
  margin-left: auto; /* with the cog, the right end of its row, also when the header wraps on phones */
}

button.icon[aria-expanded="true"], #checkButton[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Settings, capture and the export check: laid exactly over the details pane (the last grid column), which
   keeps its scroll position underneath; the viewport stays in view, so changes show as they're made. Full
   screen on phones. */
.overlay-panel {
  position: absolute;
  grid-column: -2 / -1;
  grid-row: 1;
  inset: 0;
  z-index: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 14px 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-head h2 {
  margin: 0;
  color: var(--fg);
  font-size: 15px;
}

.settings-head button {
  padding: 2px 8px;
}

.settings-label {
  margin: 8px 0 4px;
}

.save-file {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

h1 {
  font: 700 20px/1 var(--display);
  letter-spacing: .02em;
  margin: 0;
}

h1 span {
  color: var(--accent);
}

.file {
  font: 13px var(--mono);
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 120px;
}

/* the team selector, while more than one export is open: a chevron drawn with gradients so it takes the theme */
#teamSelect {
  appearance: none;
  font: 700 15px/1.2 var(--display);
  letter-spacing: .02em;
  color: var(--fg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 6px 30px 6px 10px;
  max-width: 240px;
  min-width: 0;
  text-overflow: ellipsis;
  cursor: pointer;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 15px) 50% / 5px 5px no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 10px) 50% / 5px 5px no-repeat,
    var(--accent-soft);
}

#teamSelect:hover {
  border-color: var(--accent);
}

#teamSelect:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#teamSelect:disabled {
  opacity: .6;
  cursor: progress;
}

#teamSelect option {
  font: 500 14px var(--body);
  background: var(--panel);
  color: var(--fg);
}

button, .btn {
  font: 500 14px var(--body);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}

button:hover, .btn:hover {
  border-color: var(--accent);
}

button:disabled {
  opacity: .45;
  cursor: default;
}

button:disabled:hover {
  border-color: var(--line);
}

button:focus-visible, .btn:focus-within, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
  position: relative;
}

main.has-team {
  grid-template-columns: 270px 1fr 300px;
}

aside {
  background: var(--panel);
  overflow: auto;
  padding-block: 14px;
  padding-inline: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

#details {
  border-left: 1px solid var(--line);
}

#team {
  border-right: 1px solid var(--line);
  padding-inline: 0;
  gap: 0;
}

h2 {
  font: 700 13px var(--display);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 6px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat b {
  display: block;
  font: 500 20px var(--mono);
  font-variant-numeric: tabular-nums;
}

.stat small {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.toggles {
  display: grid;
  gap: 6px;
}

label.chk {
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  min-width: 0;
}

.chk-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

/* the details pane's tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: -4px -16px 0;
  padding: 0 12px;
  position: sticky;
  top: -14px;
  z-index: 1;
  background: var(--panel);
}

.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  padding: 8px 8px 6px;
  margin-bottom: -1px;
  font: 700 13px var(--display);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.tabs button:hover {
  color: var(--fg);
  background: none;
  border-bottom-color: var(--line);
}

.tabs button[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.tab-panel[hidden] {
  display: none;
}

.anim-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  align-items: center;
  margin: 10px 0 6px;
  font-size: 13px;
}

.anim-picker select {
  width: 100%;
  min-width: 0;
}

/* a list with previous / next buttons either side */
.stepper {
  display: flex;
  gap: 4px;
  min-width: 0;
}

.stepper[hidden] {
  display: none;
}

.stepper button {
  padding: 0 8px;
  line-height: 1;
}

/* the playing clip's personalized parts, read only */
.anim-flags {
  margin-bottom: 6px;
  font-size: 13px;
}

.anim-flags .chk-row {
  flex-wrap: wrap;
  gap: 4px 14px;
}

.anim-flags label.chk {
  cursor: default;
}

input[type=color] {
  width: 32px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

input[type=checkbox] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A collapsible part of the model tree: its rail (the vertical line) collapses it to "+ Show N …". */
.branch {
  position: relative;
  margin-left: 7px;
  padding-left: 16px;
}

.rail {
  position: absolute;
  left: -7px;
  top: 0;
  bottom: 0;
  width: 15px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.rail::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.rail:hover::before, .rail:focus-visible::before {
  left: 6px;
  width: 3px;
  background: var(--accent);
}

.rail:focus-visible {
  outline: none;
}

.show-more {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: -22px;
  padding: 2px 0 2px 23px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 13px var(--body);
}

.show-more:hover {
  color: var(--accent);
}

.plus {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font: 12px/1 var(--mono);
}

/* A mesh's material name, linking to the material in the Materials list. */
.mat-link {
  padding: 0 2px;
  margin: 0 -2px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--fg);
  font: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.mat-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.mat.picked {
  background: var(--accent-soft);
  margin-inline: -8px;
  padding-inline: 8px;
  border-radius: 6px;
}

.tree li {
  padding: 2px 0;
}

.tree > ul > li > label {
  font-weight: 500;
}

.mesh {
  font: 12.5px var(--mono);
  color: var(--muted);
  white-space: pre-wrap;
}

.model-h {
  font: 700 13px var(--display);
  letter-spacing: .04em;
  margin: 10px 0 2px;
  word-break: break-all;
}

.model-h:first-child {
  margin-top: 0;
}

.mat {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}

.mat code {
  font: 12px var(--mono);
  color: var(--muted);
  word-break: break-all;
}

.tex {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font: 12px var(--mono);
  word-break: break-all;
}

.tex .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.tex.used.ok .dot {
  background: var(--accent);
}

.tex.used.missing .dot {
  background: var(--warn);
}

.kits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.kit {
  font: 500 13px var(--mono);
  padding: 5px 10px;
  font-variant-numeric: tabular-nums;
}

.kit.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

kbd {
  font: 12px var(--mono);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  background: var(--bg);
}

.linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* team roster */
.team-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.crest {
  width: 56px;
  height: 56px;
  flex: none;
  object-fit: contain;
  image-rendering: auto;
}

.crest.blank {
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.team-name {
  font: 700 24px/1.05 var(--display);
  letter-spacing: .01em;
  margin: 0;
  word-break: break-word;
  text-wrap: balance;
}

.team-meta {
  font: 12px var(--mono);
  color: var(--muted);
  margin-top: 4px;
}

.roster {
  display: flex;
  flex-direction: column;
  padding-block: 6px;
}

.player {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px 16px;
  border-left: 3px solid transparent;
}

button.player:hover {
  background: var(--bg);
}

.player.on {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.player.static {
  opacity: .72;
  cursor: default;
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  object-fit: cover;
  display: grid;
  place-items: center;
  font: 500 14px var(--mono);
  color: var(--muted);
  overflow: hidden;
}

.pname {
  font-weight: 500;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pname .num {
  font: 12px var(--mono);
  color: var(--muted);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.pmeta {
  font-size: 12.5px;
  color: var(--muted);
}

.roster-h {
  padding: 12px 16px 4px;
}

.roster-hint {
  padding: 0 16px 4px;
  font-size: 12.5px;
}

#stage {
  position: relative;
  background: var(--viewport);
  min-height: 0;
  min-width: 0;
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#drop {
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  font: 700 22px var(--display);
  color: var(--accent);
  background: color-mix(in srgb, var(--viewport) 80%, transparent);
  pointer-events: none;
}

#help {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font: 12px var(--mono);
  color: var(--muted);
  pointer-events: none;
}

/* Messages stack in the viewport's top-right corner, clear of the controls hint at the bottom. */
#notices {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(420px, calc(100% - 24px));
  pointer-events: none;
}

#notices > * {
  pointer-events: auto;
}

#status {
  font: 12px var(--mono);
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  overflow-wrap: anywhere;
}

#err {
  position: relative;
  padding: 10px 36px 10px 12px;
  background: var(--panel);
  border: 1px solid var(--warn);
  border-radius: 8px;
  color: var(--fg);
  font-size: 14px;
  overflow-wrap: anywhere;
}

#err button {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
}

@media (max-width: 1000px) {
  main, main.has-team {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 58vh) auto auto;
    overflow: auto;
  }
  #stage {
    order: -1;
  }
  aside {
    overflow: visible;
  }
  #details {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  #team {
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .overlay-panel {
    position: fixed;
    z-index: 3;
    border-left: 0;
  }
}

/* body shape */
.body-sliders {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 2.5em;
  gap: 2px 10px;
  align-items: center;
  font-size: 13px;
}

.body-sliders input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}

.body-sliders output {
  font: 12px var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* the face editor: replaces the details pane's sections while it's open */
#faceEditor, #details.face-editing > :not(#faceEditor) {
  display: none;
}

#details.face-editing > #faceEditor {
  display: block;
}

#openFaceEditor {
  margin-top: 8px;
}

.face-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.face-editor-head h2 {
  margin: 0;
}

.face-editor-head button {
  padding: 2px 10px;
}

.body-sliders.look select {
  width: 100%;
  min-width: 0;
}

.body-sliders.look input[type=color] {
  width: 40px;
}

#faceSliders h3 {
  font: 600 12px var(--display);
  color: var(--muted);
  margin: 14px 0 4px;
}

/* the export's team in the save file */
.save-link {
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.save-link-row {
  display: flex;
  gap: 6px;
}

.save-link-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: inherit;
}

#bodyNote {
  margin-top: 6px;
}

/* capture */
.capture-size {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.capture-size input, label.field input {
  font: 13px var(--mono);
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: inherit;
  min-width: 0;
}

.capture-size input {
  width: 5.5em;
}

label.field {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

label.field input {
  font: inherit;
  color: var(--fg);
}

label.field input[aria-invalid="true"] {
  border-color: var(--warn);
}

.hint.warn {
  color: var(--warn);
  margin: -4px 0 8px;
}

#captureSave {
  width: 100%;
  margin-bottom: 6px;
}

/* export check */
.check-summary {
  font: 500 14px var(--body);
}

.check-group {
  margin-bottom: 14px;
}

.check-group > h3, .check-group > button {
  display: block;
  width: 100%;
  text-align: left;
  font: 700 14px var(--display);
  letter-spacing: .02em;
  margin: 0 0 4px;
}

.check-group > h3 {
  padding: 6px 0;
}

.check-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.issue {
  font-size: 13px;
  line-height: 1.35;
  padding-left: 16px;
  position: relative;
  overflow-wrap: anywhere;
}

.issue::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .45em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.issue.error::before {
  background: #d23c3c;
}

.issue.warn::before {
  background: var(--warn);
}

#captureGrid .chk-row {
  margin-bottom: 8px;
}
