/* Galería -- the weekend-grouped photo/video feed, its detail page and the
   pilot grid (spec docs/superpowers/specs/2026-09-22-media-feed-design.md). */

/* Every other page stylesheet carries this same body block (see
   profile.css) -- galeria.css never got one, so any page that loads it
   without also loading a page stylesheet that does (pilot_galeria.html,
   galeria.html, galeria_detail.html) rendered on the browser's default
   white background and serif font instead of the dark theme. */
body {
  margin: 0; background: var(--ink);
  color: var(--text-primary); font-family: var(--font-display); -webkit-font-smoothing: antialiased;
  font-size: 15px; line-height: 1.5;
}

/* ---------- Detail ---------- */
.gd-wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.gd-crumb { margin-bottom: 12px; }
.gd-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.gd-who { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.gd-author { display: flex; align-items: center; gap: 8px; color: inherit; }
.gd-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-2); display: inline-block; }
.gd-when { font-size: 11.5px; color: var(--text-tertiary); }
.gd-media { position: relative; background: #000; }
.gd-slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
.gd-slide { flex: 0 0 100%; width: 100%; max-height: 80vh; object-fit: contain; scroll-snap-align: center; }
.gd-video { width: 100%; max-height: 80vh; display: block; }
/* A Reel with text in its letterbox (TL-006): on the page the media box is the clip's 9:16 frame (at most
   80vh tall, like the clip), so the text in the bars shows instead of spilling over the card. */
.gd-mode-page .gd-media.gd-framed { width: min(100%, 45vh); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; }
.gd-mode-page .gd-framed .gd-video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.gd-count { position: absolute; right: 10px; bottom: 10px; font-size: 11px; color: #fff; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.gd-count-hint { display: none; }
.gd-slide-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: none; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(0,0,0,.55); color: #fff; font-size: 24px; line-height: 1;
}
.gd-slide-nav:hover { background: rgba(0,0,0,.78); }
.gd-slide-nav[hidden] { display: none; }
.gd-slide-nav.prev { left: 10px; }
.gd-slide-nav.next { right: 10px; }
/* A touch screen swipes: no arrows, and the counter says so. */
@media (hover: none) {
  .gd-slide-nav { display: none; }
  .gd-count-hint { display: inline; }
}
.gd-race { margin: 12px 14px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.gd-race-l1 { font-weight: 800; font-size: 14px; }
.gd-race-l1.p1 { color: var(--gold); }
.gd-race-l1.podium { color: var(--accent); }
.gd-race-l2 { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }
.gd-race-l2 a { color: var(--accent); }
.gd-caption { margin: 10px 14px 0; font-size: 14px; line-height: 1.55; }
.gd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 14px; font-size: 13px; color: var(--text-secondary); }
.gd-kudos { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: inherit; cursor: pointer; font: inherit; }
.gd-comment-count { display: inline-flex; align-items: center; gap: 5px; }
/* The card's action icons (_galeria_card.html); the viewer draws them larger, rail-style (galeria_viewer.css). */
.gd-ico { width: 16px; height: 16px; flex: none; }
.gd-kudos.on .gd-ico { fill: currentColor; }
.gd-kudos.on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.gd-pin-form { margin-left: auto; }
/* "Quién lo ve" on the author's own Reel (reel visibility spec RV-004). */
.gd-visibility-form { margin: 0; }
.gd-visibility { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.gd-visibility select { font: inherit; font-size: 13px; }
.gd-pin { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: inherit; cursor: pointer; font: inherit; }
.gd-pin svg { width: 14px; height: 14px; }
.gd-pin.on { border-color: var(--gold); color: var(--gold); }
.gd-download { display: inline-flex; align-items: center; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: inherit; cursor: pointer; font: inherit; text-decoration: none; }
.gd-download[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.gd-delete { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: inherit; cursor: pointer; font: inherit; }
.gd-delete svg { width: 14px; height: 14px; }
.gd-delete:hover, .gd-delete:focus-visible { border-color: var(--critical); color: var(--critical); }
.gd-comments { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.gd-comment-form { display: flex; gap: 8px; margin-top: 4px; }
.gd-comment-form input[type="text"] { flex: 1; min-width: 0; }
.gd-nav { display: flex; justify-content: space-between; margin-top: 12px; font-size: 13px; }

/* ---------- Tiles (shared: feed, profile, pilot grid) ---------- */
.mt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.mt-cell { position: relative; display: block; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 6px; background: var(--surface-2); color: #fff; }
.mt-cell picture { display: contents; }
.mt-cell img, .mt-cell video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.mt-cell:hover img, .mt-cell:hover video { transform: scale(1.04); }
.mt-icon { position: absolute; top: 6px; right: 7px; font-size: 12px; text-shadow: 0 1px 3px #000; }
/* A solid gold disc with a pin, readable on any photo (the bare emoji it replaces vanished into them). */
.mt-pinned { position: absolute; top: 8px; left: 8px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #000; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.mt-pinned svg { width: 15px; height: 15px; }
.mt-official { position: absolute; top: 6px; left: 6px; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 2px 9px; border-radius: 999px; background: rgba(8, 10, 14, .58); color: #fff; border: 1px solid rgba(255, 255, 255, .22); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.mt-race { position: absolute; left: 5px; bottom: 5px; max-width: calc(100% - 10px); padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; background: rgba(0,0,0,.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-fecha { position: absolute; top: 6px; right: 6px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(8, 10, 14, .58); color: #fff; border: 1px solid rgba(255, 255, 255, .22); }
.mt-race.p1 { color: var(--gold); }
.mt-race.podium { color: var(--accent); }

/* ---------- Feed page ---------- */
.gl-wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.gl-head h1 { font-size: 22px; margin: 0 0 10px; }
.gl-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.gl-tab { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-secondary); font-size: 12.5px; }
.gl-tab.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.gl-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px; }
.gl-filters select { font-size: 12.5px; padding: 5px 28px 5px 10px; }
.gl-filters button { font: inherit; font-size: 12.5px; padding: 5px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text-primary); }
.gl-podios { font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.gl-clear { font-size: 12px; color: var(--text-tertiary); }
.gl-group { margin-bottom: 22px; }
.gl-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 2px 8px; }
.gl-group-head a { color: inherit; font-size: 14px; }
.gl-group-head a { margin-right: auto; }
.gl-collapse { background: none; border: 0; color: var(--text-tertiary); cursor: pointer; padding: 2px; display: inline-flex; align-self: center; }
.gl-collapse:hover { color: var(--text-primary); }
.gl-collapse svg { width: 18px; height: 18px; transition: transform .15s; }
.gl-group.is-collapsed .gl-collapse svg { transform: rotate(-90deg); }
.gl-group.is-collapsed .mt-grid, .gl-group.is-collapsed .gl-see-all { display: none; }
.gl-group.is-collapsed .gl-group-head { margin-bottom: 0; }
.gl-group-head span { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.gl-see-all, .gl-more { display: block; text-align: center; margin-top: 10px; font-size: 13px; color: var(--accent); }
.gl-more { padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.gl-empty { padding: 40px 16px; text-align: center; color: var(--text-secondary); }

/* ---------- Pilot grid page ---------- */
.pg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
/* Publishing is a button, not a form that is always open above the photos. */
.gl-compose { margin-bottom: 14px; }
.gl-compose > summary { display: inline-flex; list-style: none; }
.gl-compose > summary::-webkit-details-marker { display: none; }
.gl-compose[open] > summary { margin-bottom: 10px; }
.pg-count { font-size: 12.5px; color: var(--text-tertiary); }
.pg-edit, .pg-done { margin-left: auto; font: inherit; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; border: 0; background: var(--surface-2); color: var(--text-soft); cursor: pointer; }
.pg-edit:hover { background: var(--surface-hover); color: var(--text-primary); }
.pg-done { flex-shrink: 0; padding: 9px 24px; font-size: 13px; font-weight: 700; background: var(--accent); color: #04150c; }
.pg-done:hover { background: var(--accent-strong); }
/* The editor bar: the instruction on the left where it can't be missed, Listo on the right. */
.grid-save:not([hidden]) { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--accent-line); border-radius: 12px; background: var(--accent-soft); }
.pg-hint { flex: 1; min-width: 0; margin: 0; font-size: 14px; line-height: 1.45; font-weight: 500; color: var(--text-primary); }
@media (max-width: 640px) { .grid-save:not([hidden]) { flex-direction: column; align-items: stretch; } .pg-done { margin-left: 0; } }
.grid-notice { font-size: 12px; color: var(--gold); margin: 0 0 8px; min-height: 1em; }

/* ---------- Owner's uploader ---------- */
.gl-uploader-wrap { position: relative; margin-bottom: 16px; }
/* The mode radios stay in the DOM (so the labels work with no JS) but out of sight. */
.gl-mode { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.gl-uploader-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.gl-uploader-tabs label {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-secondary); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
#gl-mode-photo:checked ~ .gl-uploader-tabs label[for="gl-mode-photo"],
#gl-mode-video:checked ~ .gl-uploader-tabs label[for="gl-mode-video"],
#gl-mode-lap:checked ~ .gl-uploader-tabs label[for="gl-mode-lap"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
#gl-mode-photo:focus-visible ~ .gl-uploader-tabs label[for="gl-mode-photo"],
#gl-mode-video:focus-visible ~ .gl-uploader-tabs label[for="gl-mode-video"],
#gl-mode-lap:focus-visible ~ .gl-uploader-tabs label[for="gl-mode-lap"] { outline: 2px solid var(--accent); outline-offset: 2px; }
/* One form at a time: each form shows only while its own radio is the checked one. */
.gl-uploader-wrap > .gl-uploader { display: none; }
#gl-mode-photo:checked ~ .gl-uploader-photo,
#gl-mode-video:checked ~ .gl-uploader-video,
#gl-mode-lap:checked ~ .gl-uploader-lap { display: flex; }
.gl-uploader { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.gl-uploader > select { width: 100%; }
.gl-caption {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font: inherit; font-size: 13px; color: var(--text-primary);
}
.gl-caption::placeholder { color: var(--text-tertiary); }
.gl-uploader-note { flex: 1 1 200px; min-width: 0; font-size: 11.5px; color: var(--text-tertiary); }
/* flex-wrap + min-width:0: the visibility chip wraps a <select> as wide as its longest
   option, and without them the row can't wrap and pushes the button off a phone screen. */
.gl-uploader-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gl-uploader-row .btn-primary { margin-left: auto; }
.composer-chip {
  display: inline-flex; align-items: center; min-width: 0; max-width: 100%; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px;
  padding: 7px 11px; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease;
}
.composer-chip:hover { border-color: var(--line-hover); color: var(--text-primary); }
.composer-chip.has-file { border-color: var(--accent-line); color: var(--accent); }
.composer-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
/* A select inside a chip: no field of its own, just the text and the chevron. */
.composer-chip select {
  background-color: transparent; border: none; color: inherit; font-size: 12px; font-weight: 600;
  padding: 0 18px 0 0; background-position: right 0 center; background-size: 10px; min-width: 0; max-width: 220px;
}

/* ---------- Grid editor (grid_editor.js) ---------- */
.editing .mt-cell { outline: 2px dashed var(--accent); outline-offset: -4px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.editing .mt-cell:hover { outline-style: solid; }
.editing .mt-cell:hover img, .editing .mt-cell:hover video { transform: none; }
.editing .mt-cell.dragging { opacity: .8; cursor: grabbing; outline-style: solid; transform: scale(.94); box-shadow: 0 12px 28px rgba(0,0,0,.5); z-index: 2; }
.mt-grip { display: none; }
.editing .mt-grip { display: grid; place-items: center; position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #04150c; box-shadow: 0 2px 8px rgba(0,0,0,.45); pointer-events: none; }
.editing .mt-grip svg { width: 20px; height: 20px; }

/* ---------- Lightbox (official photos; shared with event galleries, profile.css and event_detail.css) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 10, 0.93); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.lightbox[hidden] { display: none; }
.lb-figure { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0 4vw; }
.lb-img { max-width: 88vw; max-height: 82vh; object-fit: contain; border-radius: 8px; box-shadow: 0 24px 70px -24px rgba(0,0,0,0.85); }
.lb-cap { font-size: 13px; color: rgba(255,255,255,0.72); font-weight: 600; }
.lb-cap[hidden] { display: none; }
.lb-close, .lb-nav {
  position: fixed; display: grid; place-items: center; color: #fff;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.14); line-height: 1;
  transition: background 0.15s ease;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,0.24); }
.lb-close { top: 18px; right: 20px; width: 42px; height: 42px; border-radius: 10px; font-size: 26px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; font-size: 30px; }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }
.lightbox.single .lb-nav, .lightbox.single .lb-counter { display: none; }
.lb-counter { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em; color: rgba(255,255,255,0.7); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .lb-nav { width: 42px; height: 42px; font-size: 24px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

/* ---------- Flash messages (pilot_galeria.html, galeria_detail.html; same pattern as profile.css) ---------- */
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 15px; border-radius: 10px; font-size: 13px; }
.msg.success { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent); }
.msg.error { background: rgba(255,84,112,0.1); border: 1px solid rgba(255,84,112,0.35); color: var(--critical); }
.msg.warning { background: rgba(245,166,35,0.1); border: 1px solid rgba(245,166,35,0.35); color: var(--amber); }

/* Inside the profile shell (this page now carries the identity sidebar),
   the column already sets the width and the gutter. */
.shell .gl-wrap { max-width: none; margin: 0; padding: 0; }
/* Tiles the size the Resumen tab's "Fotos y videos" card shows them. This
   page has no rail, so above profile.css's 1100px breakpoint its column
   also spans the rail track (300px + 22px gap) -- and unlike the Resumen
   card it has no 24px padding + 1px border each side. Without the cap the
   same three columns rendered 363px tiles here against 239px there. */
@media (min-width: 1101px) {
  .shell:not(.has-rail) .gl-wrap .mt-grid:not(.pg-grid) { max-width: calc(100% - 372px); }
}
/* The pilot grid (pilot_galeria.html) is four across instead, filling the
   whole column -- that is what keeps its tiles near Resumen's size, so it
   takes no cap. Three on a phone, where four would be thumbnails. */
.mt-grid.pg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .mt-grid.pg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- /galeria/ itself (.gl-feed) ----------
   The account/directory width (900px, as Equipos, Circuitos, Planes) and the
   shared .page-head, instead of a 760px column with a bare 22px h1. Each race
   weekend is a card, and its grid fills the card with as many columns as fit
   rather than three fixed ones -- a weekend with one photo was one 240px
   square in a sea of background. Scoped to .gl-feed: .gl-wrap is also the
   pilot grid page (pilot_galeria.html), which keeps its own layout. */
.gl-wrap.gl-feed { max-width: 900px; padding: 0 20px 80px; }
.gl-feed .gl-head { margin-bottom: 18px; }
.gl-feed .gl-filters { margin-bottom: 0; }
.gl-feed .gl-tab { padding: 6px 14px; font-size: 13px; }
.gl-feed .gl-group {
  margin-bottom: 18px; padding: 18px;
  background: linear-gradient(175deg, var(--surface) 0%, var(--card-gradient-end) 100%);
  border: 1px solid var(--line); border-radius: 16px;
}
.gl-feed .gl-group-head { margin: 0 0 14px; }
.gl-feed .gl-group.is-collapsed .gl-group-head { margin-bottom: 0; }
.gl-feed .gl-group-head a { font-size: 15px; }
.gl-feed .gl-group-head a:hover { color: var(--accent); }
.gl-feed .mt-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.gl-feed .mt-cell { border-radius: 10px; }
@media (max-width: 640px) {
  .gl-feed .gl-group { padding: 12px; }
  .gl-feed .mt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .gl-feed .gl-group-head { flex-direction: column; gap: 2px; }
  .gl-feed .gl-collapse { align-self: flex-start; }
}

/* A tile whose image failed to load (galeria_viewer.js marks it): a quiet
   placeholder instead of the browser's broken-image glyph. */
.mt-cell.is-broken img { visibility: hidden; }
.mt-cell.is-broken::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; opacity: .35;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='10' r='1.6'/%3E%3Cpath d='M21 16l-5-5-8 8'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='10' r='1.6'/%3E%3Cpath d='M21 16l-5-5-8 8'/%3E%3C/svg%3E") center / contain no-repeat;
}
