/* ==========================================================
   ARQUIVO — Identidade visual
   Playfair Display (display) + Archivo (corpo)
   Negro de sala de cinema, dourado, motivo de película
   ========================================================== */

:root {
  --bg:      #0D0C0B;
  --panel:   #151311;
  --panel-2: #1C1916;
  --line:    #2A2620;
  --ink:     #EDE8DF;
  --muted:   #8F877A;
  --gold:    #C9A15C;
  --gold-dk: #9A7838;
  --danger:  #C25B4E;
  --ok:      #7FA96B;
  --radius:  10px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

::selection { background: var(--gold); color: var(--bg); }

/* ----- Barras letterbox fixas (assinatura cinematográfica) ----- */
body::before, body::after {
  content: '';
  position: fixed;
  left: 0; right: 0;
  height: 6px;
  background: #000;
  z-index: 90;
  pointer-events: none;
}
body::before { top: 0; border-bottom: 1px solid var(--line); }
body::after  { bottom: 0; border-top: 1px solid var(--line); }

/* ----- Layout base ----- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

header.site {
  padding: 40px 0 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand .eyebrow {
  font-size: 11px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.brand h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: 0.01em;
}
.brand h1 em { font-style: italic; color: var(--gold); }

nav.actions { display: flex; gap: 10px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn.gold  { background: var(--gold); border-color: var(--gold); color: #171310; font-weight: 600; }
.btn.gold:hover { background: var(--gold-dk); border-color: var(--gold-dk); color: var(--ink); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ==========================================================
   LOGIN — cartão letterbox centrado
   ========================================================== */
.login-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.login-card .bar {
  height: 34px;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 14px,
      var(--bg) 14px 26px) ,
    #000;
  border-bottom: 1px solid var(--line);
}
.login-card .bar.bottom { border-bottom: 0; border-top: 1px solid var(--line); }
.login-body { padding: 36px 34px 30px; text-align: center; }
.login-body .eyebrow {
  font-size: 10px; letter-spacing: 0.4em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 10px;
}
.login-body h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  margin-bottom: 4px;
}
.login-body p.sub { color: var(--muted); font-size: 14px; margin-bottom: 26px; }

.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 12px 14px;
  transition: border-color .2s;
}
.field input:focus { outline: none; border-color: var(--gold); }

.msg-error {
  background: rgba(194, 91, 78, .12);
  border: 1px solid rgba(194, 91, 78, .4);
  color: #E4A79E;
  font-size: 14px;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.msg-ok {
  background: rgba(127, 169, 107, .12);
  border: 1px solid rgba(127, 169, 107, .4);
  color: #B9D3AC;
  font-size: 14px;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ==========================================================
   PÁGINA DE ANOS — película de filme
   ========================================================== */
.years-intro { color: var(--muted); max-width: 560px; margin-bottom: 36px; font-size: 15px; }

.filmstrip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
  padding-bottom: 60px;
}

.frame {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .25s, border-color .25s;
}
.frame:hover { transform: translateY(-4px); border-color: var(--gold); }
.frame:focus-within { border-color: var(--gold); }

/* perfurações de película em cima e em baixo */
.frame .sprockets {
  height: 22px;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 12px,
      var(--bg) 12px 22px);
  background-color: #060505;
}
.frame .sprockets.top { border-bottom: 1px solid var(--line); }
.frame .sprockets.bottom { border-top: 1px solid var(--line); }

.frame a.frame-link { display: block; }
.frame .frame-body {
  padding: 34px 26px 30px;
  text-align: center;
}
.frame .year {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 52px;
  line-height: 1;
  color: var(--ink);
  transition: color .25s;
}
.frame:hover .year { color: var(--gold); }
.frame .label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  min-height: 1.2em;
}
.frame .count {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dk);
}

/* ----- Fotograma com capa fotográfica ----- */
.frame-cover {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--panel-2);
}
.frame-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity .5s, transform .6s;
}
.frame-cover img.loaded { opacity: 1; }
.frame.has-cover:hover .frame-cover img { transform: scale(1.08); }
.frame-cover .cover-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,5,4,.05) 40%, rgba(6,5,4,.82) 100%);
}
.frame-cover .cover-info {
  position: absolute;
  left: 18px; right: 18px; bottom: 14px;
}
.frame-cover .cover-info .year {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 44px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 12px rgba(0,0,0,.55);
  transition: color .25s;
}
.frame.has-cover:hover .cover-info .year { color: var(--gold); }
.frame-cover .cover-info .meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(237, 232, 223, .85);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
  color: var(--muted);
}
.empty-state .big {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--ink);
  margin-bottom: 8px;
}

/* ==========================================================
   GALERIA
   ========================================================== */
.gallery-head { margin-bottom: 8px; }
.gallery-head .year-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1;
  color: var(--ink);
}
.gallery-head .year-title em { font-style: italic; color: var(--gold); }
.gallery-meta {
  display: flex; gap: 18px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px;
  letter-spacing: 0.05em;
  margin: 14px 0 8px;
}
.gallery-meta strong { color: var(--ink); font-weight: 400; }

.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 13px; color: var(--muted);
  margin: 18px 0 26px;
}
.breadcrumb a { color: var(--gold); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--line); }

.subfolders {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 28px;
}
.folder-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color .2s, color .2s;
}
.folder-chip:hover { border-color: var(--gold); color: var(--gold); }
.folder-chip .n { color: var(--muted); font-size: 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding-bottom: 70px;
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}
.grid .cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  border: 1px solid transparent;
  transition: border-color .2s;
}
/* Skeleton shimmer enquanto a thumbnail não chega do pCloud */
.grid .cell::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(100deg,
    transparent 30%, rgba(237, 232, 223, .05) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite;
}
.grid .cell:has(img.loaded)::before { display: none; }
@keyframes shimmer {
  from { background-position: 130% 0; }
  to   { background-position: -90% 0; }
}
.grid .cell:hover { border-color: var(--gold); }
.grid .cell img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .4s;
}
.grid .cell img.loaded { opacity: 1; }
.grid .cell .name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 22px 10px 8px;
  font-size: 11px;
  color: var(--ink);
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  opacity: 0;
  transition: opacity .2s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid .cell:hover .name { opacity: 1; }

/* ----- Botão de download por fotografia ----- */
.grid .cell .dl {
  position: absolute;
  top: 8px; right: 8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: rgba(6, 5, 4, .72);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  opacity: 0;
  transition: opacity .2s, border-color .2s, color .2s;
  z-index: 2;
  backdrop-filter: blur(2px);
}
.grid .cell:hover .dl,
.grid .cell .dl:focus-visible { opacity: 1; }
.grid .cell .dl:hover { border-color: var(--gold); color: var(--gold); }
/* Em ecrãs táteis não há hover: botão sempre visível */
@media (hover: none) {
  .grid .cell .dl { opacity: 1; }
}

/* ==========================================================
   SELEÇÃO MÚLTIPLA
   ========================================================== */
.grid .cell .sel {
  position: absolute;
  top: 8px; left: 8px;
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 2px solid rgba(237, 232, 223, .9);
  background: rgba(6, 5, 4, .55);
  cursor: pointer;
  opacity: .85;
  transition: opacity .2s, border-color .2s, background .2s, transform .15s;
  z-index: 3;
  padding: 0;
}
.grid .cell:hover .sel,
.grid .cell .sel:focus-visible,
.grid .cell.selected .sel { opacity: 1; }
.grid .cell .sel:hover { border-color: var(--gold); transform: scale(1.08); }
.grid .cell.selected .sel {
  background: var(--gold);
  border-color: var(--gold);
}
.grid .cell.selected .sel::after {
  content: '✓';
  display: grid; place-items: center;
  width: 100%; height: 100%;
  color: #171310;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}
.grid .cell.selected {
  border-color: var(--gold);
}
.grid .cell.selected img { opacity: .55 !important; }
@media (hover: none) {
  .grid .cell .sel { opacity: 1; }
}

.selectbar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 90px);
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--gold-dk);
  border-radius: 14px;
  padding: 12px 20px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
  z-index: 150;
  transition: transform .25s;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.selectbar.visible { transform: translate(-50%, 0); }
.selectbar .sel-count { font-size: 14px; color: var(--muted); white-space: nowrap; }
.selectbar .sel-count strong { color: var(--gold); font-weight: 600; font-size: 16px; }
.selectbar .sel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==========================================================
   PESQUISA
   ========================================================== */
.searchbar {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.searchbar input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 14px;
  width: 170px;
  transition: border-color .2s, width .25s;
}
.searchbar input:focus { outline: none; border-color: var(--gold); width: 230px; }
.searchbar input::placeholder { color: var(--muted); }

.searchbar.big {
  display: flex;
  gap: 10px;
  margin-bottom: 34px;
}
.searchbar.big input {
  flex: 1;
  width: auto;
  font-size: 17px;
  padding: 13px 18px;
}
.searchbar.big input:focus { width: auto; }

.search-year { margin-bottom: 44px; }
.search-year-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 34px;
  margin-bottom: 14px;
}
.search-year-title a { color: var(--ink); transition: color .2s; }
.search-year-title a:hover { color: var(--gold); }
.search-grid { padding-bottom: 10px; }

.grid .cell.file-generic {
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 10px;
}
.grid .cell.file-generic .ext {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--gold);
  display: block;
  margin-bottom: 6px;
}

/* ----- Lightbox ----- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(6, 5, 4, .96);
  z-index: 200;
  display: none;
  flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox .lb-top, .lightbox .lb-bottom {
  height: 54px;
  flex: 0 0 auto;
  background: #000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  font-size: 13px; color: var(--muted);
}
.lightbox .lb-top { border-bottom: 1px solid var(--line); }
.lightbox .lb-bottom { border-top: 1px solid var(--line); justify-content: center; gap: 26px; }
.lightbox .lb-stage {
  flex: 1;
  display: grid; place-items: center;
  padding: 16px;
  min-height: 0;
  position: relative;
}
.lightbox .lb-stage img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .25s;
}
.lightbox .lb-stage img.loaded { opacity: 1; }
/* Spinner enquanto a imagem grande carrega */
.lightbox .lb-spinner {
  position: absolute;
  width: 42px; height: 42px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: none;
}
.lightbox.loading .lb-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dica de teclado (só em dispositivos com rato/teclado) */
.lightbox .lb-hint {
  display: none;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (hover: hover) {
  .lightbox .lb-hint { display: block; }
}

/* ==========================================================
   TOASTS — feedback de operações
   ========================================================== */
.toasts {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(440px, calc(100vw - 24px));
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .25s, transform .25s;
  max-width: 100%;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

/* ==========================================================
   VOLTAR AO TOPO
   ========================================================== */
.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, border-color .2s, color .2s;
  z-index: 140;
}
.to-top.visible { opacity: 1; pointer-events: auto; }
.to-top:hover { border-color: var(--gold); color: var(--gold); }
.lightbox button.lb-btn {
  background: none; border: none; color: var(--ink);
  font-family: var(--font-body); font-size: 13px;
  letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; padding: 8px 4px;
}
.lightbox button.lb-btn:hover { color: var(--gold); }
.lightbox .lb-name { color: var(--ink); max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Checkbox de seleção dentro do lightbox */
.lightbox .lb-sel {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}
.lightbox .lb-sel:hover { color: var(--ink); }
.lightbox .lb-sel .box {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid var(--muted);
  background: transparent;
  display: grid; place-items: center;
  transition: border-color .2s, background .2s;
  flex: 0 0 auto;
}
.lightbox .lb-sel:hover .box { border-color: var(--gold); }
.lightbox .lb-sel.checked { color: var(--gold); }
.lightbox .lb-sel.checked .box {
  background: var(--gold);
  border-color: var(--gold);
}
.lightbox .lb-sel.checked .box::after {
  content: '✓';
  color: #171310;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}
@media (max-width: 560px) {
  .lightbox .lb-sel .txt { display: none; } /* só a caixa em ecrãs pequenos */
  .lightbox .lb-name { max-width: 44vw; }
}

/* ==========================================================
   ADMIN
   ========================================================== */
.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 26px;
}
.admin-section h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin-bottom: 4px;
}
.admin-section p.hint { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 760px) { .form-row { grid-template-columns: 1fr; } }

table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.list th {
  text-align: left;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); font-weight: 400;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
table.list td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.list tr:last-child td { border-bottom: 0; }
table.list .year-cell { font-family: var(--font-display); font-size: 20px; }
table.list code {
  font-size: 12px; color: var(--muted);
  background: var(--bg); padding: 3px 8px; border-radius: 5px;
}

.badge {
  display: inline-block;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line);
}
.badge.ok    { color: var(--ok); border-color: rgba(127,169,107,.5); }
.badge.warn  { color: var(--gold); border-color: rgba(201,161,92,.5); }
.badge.err   { color: var(--danger); border-color: rgba(194,91,78,.5); }

.verify-report {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 16px;
  font-size: 14px;
}
.verify-report h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 10px; }
.verify-report ul { list-style: none; }
.verify-report li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.verify-report li:last-child { border-bottom: 0; }
.verify-report .added   { color: var(--ok); }
.verify-report .removed { color: var(--danger); }
.verify-report .changed { color: var(--gold); }

footer.site {
  padding: 30px 0 40px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
