/* ═══════════════════════════════════════════════════════════════════
   PORTFOLIO — estética de planilla de Excel.
   Todo el color vive en :root (claro) y en [data-theme="dark"] (oscuro).
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Verde de Excel. Es la única marca de color del sitio. */
  --xl:        #107c41;
  --xl-dark:   #0e6b38;
  --xl-light:  #21a366;

  /* Cromo de la aplicación */
  --chrome:    #f3f2f1;
  --surface:   #ffffff;
  --edge:      #e1dfdd;

  /* Encabezados de fila y columna */
  --head-bg:   #f5f5f5;
  --head-fg:   #5f5f5f;
  --head-on:   #d5d5d5;   /* encabezado de la fila/columna seleccionada */
  --head-edge: #cfcfcf;

  /* Celdas */
  --cell:      #ffffff;
  --gridline:  #d4d4d4;
  --ink:       #1b1b1b;
  --ink-soft:  #616161;

  --sel:       var(--xl);
  --sel-fill:  rgba(16, 124, 65, .07);

  --note-bg:   #fffee1;   /* el amarillo del comentario de Excel */
  --note-edge: #d4d4b0;
  --note-ink:  #1b1b1b;
  --note-mark: #c00000;   /* el triangulito de la esquina */

  --shadow:    0 2px 10px rgba(0, 0, 0, .16), 0 0 1px rgba(0, 0, 0, .3);

  /* Aptos y Calibri son las de Excel; Carlito es el clon métrico de
     Calibri, para las máquinas que no tienen Office. */
  --font: Aptos, Calibri, Carlito, 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Medidas — app.js las pisa con lo que haya en CONFIG y con lo que
     arrastre el usuario. */
  --gutter:  52px;
  --head-h:  30px;
  --title-h: 34px;
  --tabs-h:  30px;
  --stat-h:  24px;
}

[data-theme="dark"] {
  --xl:        #2ea86a;
  --xl-dark:   #0b5c31;
  --xl-light:  #4ac07a;

  --chrome:    #1b1a19;
  --surface:   #252423;
  --edge:      #3b3a39;

  --head-bg:   #2b2a29;
  --head-fg:   #b3b0ad;
  --head-on:   #4a4846;
  --head-edge: #3b3a39;

  --cell:      #1f1e1d;
  --gridline:  #3b3a39;
  --ink:       #f3f2f1;
  --ink-soft:  #a19f9d;

  --sel:       #4ac07a;
  --sel-fill:  rgba(74, 192, 122, .1);

  --note-bg:   #3a3a2a;
  --note-edge: #57573f;
  --note-ink:  #f3f2f1;
  --note-mark: #e05252;

  --shadow:    0 2px 12px rgba(0, 0, 0, .55), 0 0 1px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

/* El atributo hidden pierde contra cualquier display: flex/grid/inline-flex
   declarado después. Se gana de una vez para todo el sitio. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--chrome);
  color: var(--ink);
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img, video { display: block; }

.sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%);
}

.skip {
  position: fixed; top: 6px; left: 6px; z-index: 999;
  padding: 8px 12px;
  background: var(--xl); color: #fff;
  font-weight: 700;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }


/* ═══════════════ CARÁTULA ═══════════════ */

.splash {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  padding: 8vh 24px;
  background: var(--xl);
  color: #fff;
  cursor: pointer;
  transition: opacity 460ms ease, visibility 460ms;
}
.splash.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }
.splash__in { text-align: center; }

.splash__icon { width: 78px; height: auto; margin: 0 auto; display: block; }
.sp-page { fill: #fff; }
.sp-fold { fill: #d6e8dd; }
.sp-tile { fill: var(--xl); }
.sp-x    { fill: #fff; }
.sp-grid { stroke: rgba(255, 255, 255, .5); stroke-width: 1.4; fill: none; }

.splash__file {
  margin: 26px 0 0;
  font-size: 19px; font-weight: 700;
  letter-spacing: .002em;
}
.splash__hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, .82);
}
.splash__hint::after {
  content: ''; display: block;
  width: 132px; height: 2px; margin: 18px auto 0;
  background: rgba(255, 255, 255, .28);
  overflow: hidden;
}
.splash__hint::before {
  content: ''; position: absolute; margin-top: 18px;
  width: 44px; height: 2px;
  background: #fff;
  animation: sweep 1.5s cubic-bezier(.5, 0, .5, 1) infinite;
  transform: translateX(-66px);
}
@keyframes sweep {
  0%   { transform: translateX(-66px); }
  100% { transform: translateX(22px); }
}


/* ═══════════════ ESTRUCTURA ═══════════════ */

.app {
  display: grid;
  grid-template-rows: var(--title-h) auto auto 1fr var(--tabs-h) var(--stat-h);
  height: 100dvh;
  opacity: 0;
  transition: opacity 340ms ease;
}
.app.is-live { opacity: 1; }


/* ═══════════════ BARRA DE TÍTULO ═══════════════ */

.titlebar {
  display: flex; align-items: center; gap: 9px;
  padding: 0 12px;
  background: var(--xl-dark);
  color: #fff;
}
.titlebar__x { flex: none; width: 17px; height: 17px; }
.titlebar__x svg { width: 100%; height: 100%; }
.titlebar__x rect { fill: #fff; }
.titlebar__x text {
  fill: var(--xl-dark); font-size: 12px; font-weight: 700;
  text-anchor: middle; font-family: var(--font);
}
.titlebar__file {
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.titlebar__saved {
  margin-left: auto; flex: none;
  font-size: 11px; color: rgba(255, 255, 255, .72);
}


/* ═══════════════ HERRAMIENTAS ═══════════════ */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--edge);
  min-height: 40px;
}
.tb__group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb__group--end { flex: none; }

.tb__ico { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; }
#shareBtn .tb__ico, #themeBtn .tb__ico { fill: currentColor; stroke: none; }

.tb__search {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px;
  min-width: 0;
  border: 1px solid var(--edge);
  border-radius: 3px;
  background: var(--cell);
  color: var(--ink-soft);
}
.tb__search:focus-within { border-color: var(--sel); }
.tb__search input {
  width: 190px; min-width: 0;
  border: 0; outline: none; background: none;
  font-size: 13px; color: var(--ink);
}
.tb__search input::placeholder { color: var(--ink-soft); }

.tb__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 3px;
  white-space: nowrap;
}
.tb__btn:hover { background: var(--head-bg); border-color: var(--edge); }
.tb__btn--icon { padding: 5px 7px; }

.tb__links { display: flex; gap: 12px; }
.tb__links a {
  font-size: 12.5px; color: var(--xl); text-decoration: none;
  white-space: nowrap;
}
.tb__links a:hover { text-decoration: underline; }


/* ═══════════════ BARRA DE FÓRMULAS ═══════════════ */

.fbar {
  display: flex; align-items: center; gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--edge);
  height: 26px;
}
.fbar__ref {
  flex: none; width: var(--gutter);
  min-width: 64px;
  padding: 0 8px;
  font-size: 12px; color: var(--ink);
  border-right: 1px solid var(--edge);
  line-height: 25px;
}
.fbar__fx {
  flex: none; padding: 0 11px;
  font-size: 12px; font-style: italic; color: var(--ink-soft);
  border-right: 1px solid var(--edge);
  line-height: 25px;
}
.fbar__fx sub { font-style: normal; font-size: 9px; }
.fbar__val {
  padding: 0 10px;
  font-size: 12.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 25px;
}


/* ═══════════════ LA PLANILLA ═══════════════ */

.gridwrap {
  overflow: auto;
  background: var(--cell);
  outline: none;
  -webkit-overflow-scrolling: touch;
}

.sheet {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  /* El fondo detrás de la última columna es el gris del cromo, como en
     Excel cuando la hoja no llega al borde. */
  background: var(--cell);
}
.sheet[hidden] { display: none; }

.sheet th, .sheet td {
  padding: 0;
  border-right: 1px solid var(--gridline);
  border-bottom: 1px solid var(--gridline);
  vertical-align: middle;      /* centrado vertical en toda la planilla */
  font-weight: 400;
  text-align: center;
}

/* ── Encabezados de columna (A, B, C) ── */
.colhead th {
  position: sticky; top: 0; z-index: 3;
  height: var(--head-h);
  background: var(--head-bg);
  color: var(--head-fg);
  border-right: 1px solid var(--head-edge);
  border-bottom: 1px solid var(--head-edge);
  font-size: 11px;
  text-align: center;
  vertical-align: middle;
  user-select: none;
}
.colhead th.is-on { background: var(--head-on); color: var(--ink); font-weight: 700; }

/* ── Esquina ── */
.corner {
  position: sticky; left: 0; top: 0; z-index: 5;
  width: var(--gutter);
  background: var(--head-bg);
  border-right: 1px solid var(--head-edge);
  border-bottom: 1px solid var(--head-edge);
}
.corner::after {
  content: ''; position: absolute; right: 3px; bottom: 3px;
  border: 5px solid transparent;
  border-right-color: #a6a6a6; border-bottom-color: #a6a6a6;
}

/* ── Números de fila ── */
.rownum {
  position: sticky; left: 0; z-index: 2;
  width: var(--gutter);
  background: var(--head-bg);
  color: var(--head-fg);
  border-right: 1px solid var(--head-edge);
  border-bottom: 1px solid var(--head-edge);
  font-size: 11px;
  text-align: center;
  vertical-align: middle;
  user-select: none;
}
.rownum.is-on { background: var(--head-on); color: var(--ink); font-weight: 700; }

/* ── Fila de campos (Fecha · Descripción · Contenido) ── */
.fieldhead th, .fieldhead td {
  position: sticky; top: var(--head-h); z-index: 2;
  height: var(--head-h);
  background: var(--head-bg);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--head-edge);
}
.fieldhead .rownum { z-index: 4; }

.field {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  padding: 0 24px;
}
.field .filt { position: absolute; right: 4px; top: 50%; margin-top: -8.5px; }
.field__t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Botón de autofiltro */
.filt {
  flex: none;
  display: grid; place-items: center;
  width: 17px; height: 17px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--ink-soft);
}
.filt:hover { background: var(--surface); border-color: var(--head-edge); }
.filt svg { width: 9px; height: 9px; fill: currentColor; }
.filt.is-active { color: var(--xl); background: var(--surface); border-color: var(--head-edge); }

/* ── Celdas ── */
.cell { position: relative; background: var(--cell); }
.cell--txt { padding: 12px 10px; font-size: 16px; }
.cell--fecha { color: var(--ink); font-size: 15px; }
.cell--desc  { font-weight: 700; font-size: 17px; line-height: 1.25; }
.cell--desc .role { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }

.cell.is-sel {
  outline: 2px solid var(--sel);
  outline-offset: -2px;
  z-index: 1;
}
.cell.is-sel::after {
  /* El cuadradito de arrastre de la esquina inferior derecha. */
  content: ''; position: absolute; right: -3px; bottom: -3px;
  width: 6px; height: 6px;
  background: var(--sel);
  border: 1px solid var(--cell);
}

/* Comentario: el triangulito rojo de la esquina */
.cell.has-note > .mark {
  position: absolute; top: 0; right: 0; z-index: 2;
  width: 0; height: 0;
  border: 5px solid transparent;
  border-top-color: var(--note-mark);
  border-right-color: var(--note-mark);
}

/* ── La celda de contenido: todos los videos del evento ── */
.clips {
  display: flex; flex-wrap: wrap;
  align-items: flex-start; justify-content: center;
  gap: 16px 18px;
  padding: 15px 12px;
  min-height: calc(var(--cliph, 148px) + 44px);
}

/* Cada miniatura comparte alto con las demás y lleva su ancho natural.
   El min-width deja lugar al pie cuando el video es vertical y angosto. */
.clip {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  min-width: 108px; max-width: 100%;
}
/* El ancho lo manda el ancho, no el alto: así, cuando la columna es más
   angosta que la miniatura, ésta se achica proporcionalmente en vez de
   desbordarse fuera de la celda. */
.clip__hit {
  position: relative; display: block;
  width: calc(var(--cliph, 148px) * var(--ar, 1.7778));
  max-width: 100%;
  aspect-ratio: var(--ar, 1.7778);
  height: auto;
  background: #000;
  border: 1px solid var(--gridline);
  overflow: hidden;
  padding: 0;
}
.clip__hit img, .clip__hit video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.clip__hit video { opacity: 0; transition: opacity 260ms ease; }
.clip__hit video.is-playing { opacity: 1; }
.clip__hit:hover { outline: 2px solid var(--sel); outline-offset: 1px; }

.clip__cap {
  font-size: 12.5px; line-height: 1.25; text-align: center;
  max-width: 100%;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
}

/* Embed de Instagram: trae su propio marco, sólo le damos el hueco. */
.clip--ig { max-width: none; }
.ig {
  display: block;
  width: 340px; max-width: 100%;
  height: calc(var(--igh, 540px) - 60px);
  border: 1px solid var(--gridline);
  background: var(--surface);
}

/* Filas ocultas por el filtro */
.sheet tr.is-out { display: none; }

/* Aviso de sin resultados */
.noresult td {
  padding: 26px 12px;
  font-size: 13px; color: var(--ink-soft);
  border-right: 0;
}

/* ── Tiradores para redimensionar ── */
.grip {
  position: absolute; z-index: 6;
  touch-action: none;
}
.grip--col {
  top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize;
}
.grip--row {
  left: 0; bottom: -3px; height: 7px; width: 100%;
  cursor: row-resize;
}
.grip:hover { background: var(--sel); opacity: .35; }
.colhead th, .rownum { position: sticky; }   /* para anclar los tiradores */

body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing-row { cursor: row-resize; user-select: none; }


/* ═══════════════ PESTAÑAS ═══════════════ */

.tabs {
  display: flex; align-items: stretch;
  gap: 0;
  padding-left: 6px;
  background: var(--chrome);
  border-top: 1px solid var(--edge);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 0 15px;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-right: 1px solid var(--edge);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { background: var(--surface); }
.tab[aria-selected="true"] {
  background: var(--cell);
  color: var(--xl);
  font-weight: 700;
  border-bottom-color: var(--xl);
}


/* ═══════════════ ESTADO ═══════════════ */

.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: var(--chrome);
  border-top: 1px solid var(--edge);
  font-size: 11.5px;
  color: var(--ink-soft);
}
.statusbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


/* ═══════════════ MENÚ DE FILTRO ═══════════════ */

.menu {
  position: fixed; z-index: 200;
  width: 236px;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 3px;
  box-shadow: var(--shadow);
  font-size: 12.5px;
}
.menu[hidden] { display: none; }

.menu__item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 12px;
  text-align: left;
}
.menu__item:hover { background: var(--head-bg); }
.menu__item svg { width: 13px; height: 13px; flex: none; fill: currentColor; }

.menu__sep { height: 1px; margin: 4px 0; background: var(--edge); }

.menu__list {
  max-height: 210px; overflow-y: auto;
  padding: 2px 0;
}
.menu__chk {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 5px 12px;
  text-align: left;
}
.menu__chk:hover { background: var(--head-bg); }
.menu__chk input { flex: none; accent-color: var(--xl); margin: 0; }
.menu__chk span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* ═══════════════ COMENTARIO ═══════════════ */

.note {
  position: fixed; z-index: 210;
  max-width: 250px;
  padding: 7px 9px;
  background: var(--note-bg);
  color: var(--note-ink);
  border: 1px solid var(--note-edge);
  box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.4;
}
.note[hidden] { display: none; }


/* ═══════════════ VISOR ═══════════════ */

.viewer {
  position: fixed; inset: 0; z-index: 250;
  display: grid; place-items: center;
  padding: 3vh 3vw;
  background: rgba(0, 0, 0, .62);
  /* Lo que ocupa el marco del visor: barra + pie + barra de progreso +
     márgenes. Se descuenta del viewport para acotar el video. */
  --vchrome: 132px;
  --vpad: 60px;
}
.viewer[hidden] { display: none; }

.viewer__win {
  display: flex; flex-direction: column;
  max-width: 100%; max-height: 100%;
  background: var(--surface);
  border: 1px solid var(--edge);
  box-shadow: 0 12px 44px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.viewer__bar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 0 11px;
  height: 30px; flex: none;
  background: var(--xl-dark);
  color: #fff;
}
.viewer__title {
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viewer__close {
  margin-left: auto; flex: none;
  width: 30px; height: 30px;
  color: #fff; font-size: 13px;
}
.viewer__close:hover { background: #c42b1c; }

.viewer__stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  padding: 8px;
}
/* Contra el viewport y no contra el padre: el alto de un flex dentro de un
   grid no es una altura definida, y sin eso un 9:16 sale a tamaño nativo y
   se va de pantalla. */
.viewer__video {
  width: auto; height: auto;
  max-width:  calc(100vw - var(--vpad));
  max-height: calc(100dvh - var(--vchrome));
}

.viewer__foot {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 6px 11px;
  font-size: 11.5px; color: var(--ink-soft);
  border-top: 1px solid var(--edge);
}
.viewer__keys { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.viewer__prog { flex: none; height: 2px; background: var(--edge); }
.viewer__prog i { display: block; height: 100%; width: 0; background: var(--xl); }

kbd {
  display: inline-block;
  padding: 1px 4px;
  font-family: var(--font); font-size: 10.5px;
  border: 1px solid var(--edge); border-radius: 2px;
  background: var(--head-bg); color: var(--ink);
}


/* ═══════════════ AVISO ═══════════════ */

.toast {
  position: fixed; z-index: 400;
  left: 50%; bottom: 46px; transform: translateX(-50%);
  padding: 9px 16px;
  background: var(--xl); color: #fff;
  font-size: 12.5px; font-weight: 700;
  border-radius: 3px;
  box-shadow: var(--shadow);
  animation: rise 200ms ease;
}
.toast[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }


/* ═══════════════ MÓVIL ═══════════════ */

@media (max-width: 720px) {
  :root { --gutter: 30px; --title-h: 32px; }

  body { font-size: 12.5px; }

  .toolbar { padding: 5px 7px; gap: 7px; min-height: 38px; }
  .tb__search input { width: 100%; }
  .tb__search { flex: 1 1 auto; }
  .tb__links { display: none; }              /* van al menú de compartir */
  .tb__btn span { display: none; }           /* sólo los íconos */
  .tb__btn { padding: 6px 8px; }

  .fbar__ref { min-width: 52px; }
  .fbar__fx  { padding: 0 8px; }

  .cell--desc .role { display: none; }
  .cell--fecha { font-size: 12.5px; }
  .cell--desc  { font-size: 14px; }
  .cell--txt { padding: 5px 5px; font-size: 14px; }
  .clips { gap: 12px 12px; padding: 11px 7px; }
  .clip { min-width: 86px; }
  .clip__cap { font-size: 11.5px; }
  .tab { padding: 0 12px; }
  .statusbar { font-size: 11px; }
  .viewer { padding: 0; --vchrome: 92px; --vpad: 16px; }
  .viewer__win { width: 100%; height: 100%; max-height: 100%; border: 0; }
  .viewer__keys { display: none; }
}

/* En pantallas muy angostas los tiradores estorban más de lo que sirven. */
@media (pointer: coarse) and (max-width: 720px) {
  .grip { display: none; }
}


/* ═══════════════ MOVIMIENTO REDUCIDO ═══════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
