/* Mapa interactivo · Pizarra de Cristal.
   Los tokens viven en ../shared/pizarra.css. Dos escenas: la biblioteca de jugadas y el editor del mapa. */

:root{ --topbar-h: 62px; --side-ally: var(--pz-mid); --side-enemy: var(--pz-top); font-family: var(--pz-font); }
body{ display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body.editing{ height: 100vh; height: 100dvh; overflow: hidden; }
button{ font-family: inherit; cursor: pointer; }
a{ color: var(--pz-chalk); text-underline-offset: 3px; }

.ic{ width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pzDraw{ from{ clip-path: inset(0 100% 0 0); } to{ clip-path: inset(0 0 0 0); } }
@keyframes strokeUp{ from{ transform: scaleY(.15); opacity: .3; } to{ transform: scaleY(1); opacity: 1; } }

/* ---------- botones ---------- */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 var(--pz-font); padding: 11px 16px; border-radius: var(--pz-radius);
  border: 1px solid var(--pz-line-strong); background: transparent; color: var(--pz-chalk);
  white-space: nowrap; text-decoration: none; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover{ background: var(--pz-glass-3); border-color: var(--pz-chalk-faint); color: var(--pz-chalk); }
.btn.primary{ background: var(--pz-chalk); border-color: var(--pz-chalk); color: var(--pz-glass); }
.btn.primary:hover{ background: #fff; border-color: #fff; }
.btn.small{ padding: 8px 12px; font-size: 13px; }
.btn:disabled{ opacity: .45; cursor: not-allowed; pointer-events: none; }
.icon-btn{
  width: 38px; height: 38px; border-radius: var(--pz-radius); border: 1px solid transparent; background: transparent;
  color: var(--pz-chalk-dim); display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: background-color .15s, border-color .15s, color .15s;
}
.icon-btn .ic{ width: 18px; height: 18px; }
.icon-btn:hover{ color: var(--pz-chalk); background: var(--pz-glass-3); border-color: var(--pz-line-strong); }
.icon-btn.danger:hover{ color: var(--pz-danger); border-color: #6a3a30; background: rgba(255,122,89,.1); }
.icon-btn:disabled{ opacity: .3; pointer-events: none; }

/* ---------- campos ---------- */
input[type=text], select, textarea{
  width: 100%; background: var(--pz-glass); color: var(--pz-chalk); border: 1px solid var(--pz-line-strong);
  border-radius: var(--pz-radius); padding: 10px 12px; font: 400 15px/1.35 var(--pz-font); transition: border-color .15s;
}
input[type=text]::placeholder, textarea::placeholder{ color: var(--pz-chalk-faint); }
input:hover, select:hover, textarea:hover{ border-color: var(--pz-chalk-faint); }
input:focus, select:focus, textarea:focus{ outline: none; border-color: var(--pz-focus); box-shadow: 0 0 0 1px var(--pz-focus); }
select{
  color-scheme: dark; appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a3aab1' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select option{ background: var(--pz-glass-2); color: var(--pz-chalk); }
textarea{ resize: vertical; line-height: 1.5; }
label.lbl{ display: block; font-size: 13px; font-weight: 600; color: var(--pz-chalk-dim); margin: 12px 0 6px; }
.check{ display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; color: var(--pz-chalk); cursor: pointer; min-height: 32px; }
.check input{ width: 18px; height: 18px; accent-color: var(--pz-adc); margin: 0; }

/* ---------- barra superior ---------- */
header.topbar{ position: sticky; top: 0; z-index: 100; background: var(--pz-glass); border-bottom: 1px solid var(--pz-line-strong); flex: 0 0 auto; }
.topbar-in{ max-width: 1680px; margin: 0 auto; padding: 12px 32px; min-height: var(--topbar-h); display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; }
.brand{ display: flex; align-items: center; gap: 14px; }
.brand-strokes{ display: inline-flex; gap: 4px; align-items: flex-end; }
.brand-strokes i{ display: block; width: 6px; height: 24px; border-radius: 2px; }
.brand-strokes i:nth-child(1){ background: var(--pz-top); }
.brand-strokes i:nth-child(2){ background: var(--pz-jg); }
.brand-strokes i:nth-child(3){ background: var(--pz-mid); }
.brand-strokes i:nth-child(4){ background: var(--pz-adc); }
.brand-strokes i:nth-child(5){ background: var(--pz-sup); }
.brand-name{ margin: 0; font-size: 26px; font-weight: 700; font-stretch: 75%; letter-spacing: .005em; line-height: 1; white-space: nowrap; }
.team-bar{ display: flex; align-items: center; gap: 8px; font-size: 14px; }
.team-bar label{ font-size: 13px; font-weight: 600; color: var(--pz-chalk-dim); white-space: nowrap; }
.team-bar select{ width: auto; max-width: 230px; padding-top: 8px; padding-bottom: 8px; font-size: 14px; }
.top-right{ margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.user-chip{ color: var(--pz-chalk-dim); white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; }
.user-chip b{ color: var(--pz-chalk); font-weight: 600; }
.readonly-badge{ font-size: 13px; font-weight: 600; color: var(--pz-adc); border: 1px solid color-mix(in srgb, var(--pz-adc) 45%, transparent); border-radius: 6px; padding: 4px 10px; }
.sync-indicator{ display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--pz-chalk-dim); white-space: nowrap; }
.sync-indicator::before{ content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--pz-top); }

/* ---------- biblioteca ---------- */
#viewLibrary{ width: 100%; max-width: 1680px; margin: 0 auto; padding: 36px 32px 96px; }
.lib-head{ display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title{ margin: 0; font-size: 40px; font-weight: 700; font-stretch: 75%; line-height: 1.05; letter-spacing: .005em; text-wrap: balance; }
.page-title .pz-stroke::after{ clip-path: inset(0 0 0 0); animation: pzDraw .7s var(--pz-ease) .2s both; }
.page-sub{ margin: 12px 0 0; color: var(--pz-chalk-dim); font-size: 14px; }
.lib-filters{ display: flex; gap: 12px 20px; align-items: center; flex-wrap: wrap; margin-bottom: 28px; }
.search{ position: relative; flex: 0 1 360px; min-width: 220px; }
.search .ic{ position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--pz-chalk-faint); pointer-events: none; width: 17px; height: 17px; }
.search input{ padding-left: 40px; }
.search.small input{ padding: 8px 10px 8px 36px; font-size: 14px; }
.search.small .ic{ left: 11px; width: 16px; height: 16px; }

.plays{ display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 28px 24px; }
.play{ display: block; min-width: 0; }
.play-open{
  display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; border-radius: var(--pz-radius-lg);
}
.play-thumb{
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--pz-glass-2);
  border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius-lg); transition: border-color .15s;
}
div.play-thumb{ display: grid; place-items: center; color: var(--pz-chalk-faint); font-size: 13px; }
.play-open:hover .play-thumb, .play-open:focus-visible .play-thumb{ border-color: var(--pz-chalk-faint); }
.play-row{ display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 12px; }
.play-title{ margin: 0; font-size: 18px; font-weight: 600; line-height: 1.25; text-wrap: balance; overflow-wrap: anywhere; }
.play-meta{ margin: 4px 0 0; font-size: 13px; color: var(--pz-chalk-dim); }
.play-acts{ display: flex; flex-shrink: 0; margin: -6px -6px 0 0; }

.empty{ border: 1px dashed var(--pz-line-strong); border-radius: var(--pz-radius-lg); padding: 60px 24px; text-align: center; }
.empty h3{ margin: 0 0 10px; font-size: 30px; font-weight: 700; font-stretch: 75%; line-height: 1.1; text-wrap: balance; }
.empty p{ margin: 0 auto 22px; max-width: 540px; line-height: 1.55; font-size: 15px; color: var(--pz-chalk-dim); }
.empty .row{ display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- editor ---------- */
#viewEditor{ flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ed-bar{
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; padding: 10px 16px;
  background: var(--pz-glass); border-bottom: 1px solid var(--pz-line);
}
.ed-bar .spacer{ flex: 1; }
.ed-title{ flex: 1 1 260px; max-width: 460px; min-width: 160px; font-size: 18px; font-weight: 700; font-stretch: 75%; padding: 8px 12px; }
.ed-phase{ width: auto; padding-top: 9px; padding-bottom: 9px; font-size: 14px; }
.ed-state{ display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--pz-chalk-dim); white-space: nowrap; }
.ed-state::before{ content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--pz-jg); }
.ed-state[data-s="dirty"]{ color: var(--pz-chalk); }
.ed-state[data-s="dirty"]::before{ background: var(--pz-adc); }
.ed-state[data-s="new"]::before, .ed-state[data-s="ro"]::before{ background: var(--pz-chalk-faint); }
.ed-state[data-s="saving"]::before{ background: var(--pz-adc); }

.ed-body{ flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 60px minmax(0, 1fr) 330px; }
.toolbar{
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; overflow-y: auto;
  background: var(--pz-glass); border-right: 1px solid var(--pz-line);
}
.toolbar .tb{
  width: 44px; height: 44px; border-radius: var(--pz-radius); border: 1px solid transparent; background: transparent;
  color: var(--pz-chalk-dim); display: grid; place-items: center; padding: 0; transition: background-color .15s, color .15s, border-color .15s;
}
.toolbar .tb .ic{ width: 20px; height: 20px; }
.toolbar .tb:hover{ color: var(--pz-chalk); background: var(--pz-glass-3); }
.toolbar .tb[aria-pressed="true"]{ color: var(--pz-chalk); background: var(--pz-glass-3); border-color: var(--pz-chalk); }
.toolbar .tb:disabled{ opacity: .3; pointer-events: none; }
.toolbar .sep{ width: 28px; height: 1px; background: var(--pz-line-strong); margin: 6px 0; flex-shrink: 0; }

.stage{ position: relative; min-width: 0; min-height: 0; background: #07090b; overflow: hidden; }
.stage canvas{ position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage[data-tool="pan"] canvas{ cursor: grab; }
.stage[data-tool="select"] canvas{ cursor: default; }
.stage[data-cursor="cross"] canvas{ cursor: crosshair; }
.stage[data-cursor="grabbing"] canvas{ cursor: grabbing; }
.zoom-ctl{
  position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 2px; padding: 4px;
  background: var(--pz-glass); border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius);
}
.stage-note{
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 14px;
  background: var(--pz-glass); border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius);
  font-size: 13px; font-weight: 600; color: var(--pz-chalk); text-align: center; pointer-events: none;
}
.text-input{
  position: absolute; z-index: 5; width: 220px; padding: 7px 10px; font-size: 15px; font-weight: 600;
  background: var(--pz-glass); transform: translate(-50%, -50%);
}

.panel{ overflow-y: auto; background: var(--pz-glass); border-left: 1px solid var(--pz-line); padding: 6px 18px 40px; }
.panel section{ padding: 16px 0 18px; border-bottom: 1px solid var(--pz-line); }
.panel section:last-child{ border-bottom: 0; }
.panel h2{ margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--pz-chalk-faint); }
.panel label.lbl:first-of-type{ margin-top: 0; }
.panel .lbl + select, .panel .lbl + input, .panel .lbl + textarea{ margin-bottom: 2px; }
.panel[data-readonly] #pSide ~ section:not(#pMap){ display: none; }

.seg{ display: flex; border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius); overflow: hidden; }
.seg button{
  flex: 1 1 0; min-height: 40px; padding: 8px 6px; border: 0; background: transparent; color: var(--pz-chalk-dim);
  font: 600 13px/1.1 var(--pz-font); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s, color .15s;
}
.seg button + button{ border-left: 1px solid var(--pz-line-strong); }
.seg button:hover{ color: var(--pz-chalk); background: var(--pz-glass-3); }
.seg button[aria-pressed="true"]{ background: var(--pz-chalk); color: var(--pz-glass); }
.dot{ width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.dot.blue{ background: var(--side-ally); }
.dot.red{ background: var(--side-enemy); }

.swatches{ display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.swatch{
  width: 34px; height: 34px; border-radius: var(--pz-radius); border: 2px solid var(--pz-line-strong); padding: 0; background: var(--c);
}
.swatch[aria-pressed="true"]{ border-color: var(--pz-chalk); box-shadow: 0 0 0 2px var(--pz-glass), 0 0 0 4px var(--pz-chalk); }

.champ-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin-top: 10px; max-height: 232px; overflow-y: auto; padding-right: 2px; }
.champ-grid .none{ grid-column: 1 / -1; color: var(--pz-chalk-faint); font-size: 13px; padding: 6px 2px; }
.champ{ position: relative; aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: var(--pz-radius); background: var(--pz-glass-2); overflow: hidden; }
.champ img{ width: 100%; height: 100%; display: block; object-fit: cover; }
.champ:hover{ border-color: var(--pz-chalk-faint); }
.champ[aria-pressed="true"]{ border-color: var(--pz-adc); }

.obj-row{ display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin-bottom: 12px; }
.obj{ aspect-ratio: 1; padding: 6px; border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius); background: var(--pz-glass-2); }
.obj img{ width: 100%; height: 100%; display: block; object-fit: contain; }
.obj:hover{ border-color: var(--pz-chalk-faint); background: var(--pz-glass-3); }
.row-btns{ display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- diálogo de atajos ---------- */
.dlg{ background: var(--pz-glass-2); color: var(--pz-chalk); border: 1px solid var(--pz-line-strong); border-radius: var(--pz-radius-lg); padding: 28px 30px 24px; max-width: min(460px, 92vw); width: 100%; }
.dlg::backdrop{ background: rgba(7,9,11,.72); }
.dlg h2{ margin: 0 0 16px; font-size: 28px; }
.keys{ margin: 0 0 20px; }
.keys > div{ display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--pz-line); font-size: 14px; }
.keys dt{ color: var(--pz-chalk-dim); }
.keys dd{ margin: 0; font-weight: 700; }
.dlg form{ display: flex; justify-content: flex-end; }

/* ---------- aviso y pantalla de carga ---------- */
#toast{
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(14px); z-index: 3000; opacity: 0; pointer-events: none;
  background: var(--pz-glass-3); border: 1px solid var(--pz-chalk-faint); color: var(--pz-chalk); padding: 12px 20px; border-radius: var(--pz-radius);
  font-size: 14px; transition: opacity .25s, transform .25s var(--pz-ease); max-width: min(560px, 92vw); text-align: center;
}
#toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }
#loadingVeil{ position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; background: var(--pz-glass); transition: opacity .28s ease; }
#loadingVeil.is-leaving{ opacity: 0; pointer-events: none; }
#loadingVeil .loading-mark{ display: flex; align-items: center; gap: 14px; }
#loadingVeil .brand-strokes i{ width: 8px; height: 34px; animation: strokeUp .7s var(--pz-ease) both; transform-origin: bottom; }
#loadingVeil .brand-strokes i:nth-child(2){ animation-delay: .08s; }
#loadingVeil .brand-strokes i:nth-child(3){ animation-delay: .16s; }
#loadingVeil .brand-strokes i:nth-child(4){ animation-delay: .24s; }
#loadingVeil .brand-strokes i:nth-child(5){ animation-delay: .32s; }
#loadingVeil .loading-text{ font-size: 38px; font-weight: 800; font-stretch: 62%; letter-spacing: .03em; line-height: 1; }

@media (max-width: 900px){
  body.editing{ height: auto; overflow: visible; }
  #viewLibrary{ padding: 24px 16px 80px; }
  .topbar-in{ padding: 12px 16px; }
  .top-right{ margin-left: 0; }
  .page-title{ font-size: 32px; }
  .plays{ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 14px; }
  .ed-bar{ padding: 10px 16px; }
  .ed-title{ flex-basis: 100%; max-width: none; }
  .ed-body{ grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; }
  .toolbar{ flex-direction: row; justify-content: flex-start; padding: 6px 12px; border-right: 0; border-bottom: 1px solid var(--pz-line); overflow-x: auto; overflow-y: hidden; }
  .toolbar .sep{ width: 1px; height: 28px; margin: 0 6px; }
  .stage{ aspect-ratio: 1; max-height: 72vh; }
  .panel{ border-left: 0; border-top: 1px solid var(--pz-line); overflow: visible; padding: 6px 16px 60px; }
  .text-input{ width: 180px; }
  .seg button{ min-height: 44px; }
  .swatch{ width: 44px; height: 44px; }
  .icon-btn{ width: 44px; height: 44px; }
  .check{ min-height: 44px; }
}
