/* Media Sharer — styled to match bizlake.net.
 *
 * The site stylesheet (config.php -> 'site_css') loads first and supplies the
 * tiled background, Courier body text and Impact headings. This file lays the
 * gallery out on top of it in the same palette.
 *
 * Palette lifted from the site: cyan text on black, magenta chrome, red
 * headings, dashed/ridged borders.
 */

:root {
  --bg:        #000000;
  --panel:     rgba(0, 0, 0, .9);   /* .content-box on the site */
  --ink:       #a6e3e6;
  --ink-soft:  #6f9b9d;
  --cyan:      rgb(131, 234, 252);
  --magenta:   #640064;
  --deep:      #490049;
  --link:      #7676ff;
  --hot:       #ff0000;
  --well:      #2c1616;             /* the site's <pre> background */
  --mono:      'Courier New', Courier, monospace;
  --display:   Impact, Charcoal, sans-serif;
}

* { box-sizing: border-box; }

body {
  /* Background image, font and colour come from the site stylesheet; only
     fall back here so the album still looks deliberate on its own. */
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  margin: 0;
}
body.locked { overflow: hidden; }

/* The site stylesheet supplies these; restate them at the same values so the
   album still looks like itself when 'site_css' is empty. Identical values
   mean this changes nothing when the site sheet is loaded. */
h1, h2, h3 {
  font-family: var(--display);
  color: var(--hot);
  text-shadow: 2px 2px #000000;
  margin: 10px;
}
.topbar, .foot {
  background-color: var(--magenta);
  color: #ffffff;
  padding: 10px;
  text-transform: uppercase;
}
.topbar { border-bottom: 5px double #000000; }

.muted { color: var(--ink-soft); }
.small { font-size: .8rem; }
.error { color: var(--hot); font-weight: bold; }
.error.block {
  white-space: pre-wrap;
  background: var(--well);
  border: 2px inset #dadada;
  padding: 1rem;
  margin: 1rem auto;
  max-width: 1100px;
  font-size: .85rem;
}

/* The site puts content in a centred translucent box; match it, but wider,
   because a photo grid at 800px is a two-column grid. */
.topbar, .uploader, main, .foot {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* --------------------------------------------------- inherited-rule fixes */

/* The site sets a 4px border and padding on every img. That is right for a
   page of screenshots and wrong for a thumbnail grid — it breaks object-fit
   sizing and doubles up with the tile's own frame. */
.tile-open img,
.lb-stage img,
.admin-table img {
  border: 0;
  padding: 0;
}

/* The site's button rule sets colour and background-color to the same value,
   so label text disappears. Restate both. */
button, .btn {
  font-family: var(--mono);
  font-size: .85rem;
  font-weight: bold;
  color: var(--ink);
  background-color: var(--deep);
  border: 3px outset #ffebeb;
  padding: .35rem .8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-transform: uppercase;
}
button:hover, .btn:hover {
  color: #ffffff;
  background-color: var(--magenta);
}
button:active, .btn:active { border-style: inset; }
.btn.ghost { background-color: #1a1a1a; }
.btn.small { padding: .2rem .5rem; font-size: .75rem; }
.btn.danger { color: #ffd7d7; background-color: #6a0000; }

a { color: var(--link); text-decoration: underline; }
a:hover { color: var(--hot); background-color: yellow; }
/* ...but the buttons above are links too, and must not flip to yellow. */
a.btn:hover { background-color: var(--magenta); color: #ffffff; }

input[type=text], input[type=password] {
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--ink);
  background-color: #0d0d0d;
  border: 2px inset #dadada;
  padding: .4rem .5rem;
  width: 100%;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- login */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-card {
  width: min(30rem, 100%);
  background: var(--panel);
  border: 5px ridge gray;
  box-shadow: 10px 10px 0 #000;
  border-radius: 10px;
  padding: 2em;
}
.login-card h1 { margin-top: 0; }
.login-card label {
  display: block;
  margin: 1rem 0 .35rem;
  text-transform: uppercase;
  font-size: .8rem;
  letter-spacing: .08em;
}
.login-card button { width: 100%; margin-top: 1rem; padding: .6rem; }

/* --------------------------------------------------------------- topbar */

/* The site styles header/footer magenta and uppercase; keep that, but lay the
   contents out in a row instead of centring one line of text. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  margin-top: 1.5rem;
  border-radius: 10px 10px 0 0;
}
.topbar h1 { margin: 0; font-size: 1.6rem; }
.topbar-main p { margin: .2rem 0 0; font-size: .8rem; color: #e6c8e6; text-transform: none; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

main {
  background: var(--panel);
  border: 5px ridge gray;
  border-top: 0;
  padding: 1.5em;
}
.foot {
  background-color: var(--magenta);
  color: #ffffff;
  padding: 10px;
  border-top: 5px double #000000;
  border-radius: 0 0 10px 10px;
  text-align: center;
  text-transform: uppercase;
  font-size: .8rem;
  margin-bottom: 2rem;
}
.empty { padding: 3rem 0; text-align: center; }

/* ------------------------------------------------------------- uploader */

.uploader {
  background: var(--panel);
  border: 5px ridge gray;
  border-bottom: 0;
  padding: 1.5em;
  display: grid;
  gap: .8rem;
}
.upload-who { max-width: 24rem; }
.upload-who label {
  display: block;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .3rem;
}

/* Echoes the site's dashed-cyan nav block. */
.dropzone {
  background-color: #1a1a1a;
  border: 3px dashed var(--cyan);
  padding: 1.4rem 1rem;
  text-align: center;
  font-weight: bold;
}
.dropzone p { margin: .25rem 0; }
.dropzone strong { color: var(--cyan); }
.dropzone.hot { border-style: solid; background-color: #202a2c; }

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8rem auto;
  gap: .7rem;
  align-items: center;
  font-size: .8rem;
  background-color: var(--well);
  border: 2px inset #dadada;
  padding: .4rem .6rem;
}
.q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-bar { height: 12px; background: #000; border: 2px groove var(--cyan); overflow: hidden; }
.q-fill { display: block; height: 100%; width: 0; background: var(--cyan); }
.q-status { color: var(--ink-soft); white-space: nowrap; }
.queue-row.done .q-status { color: var(--cyan); }
.queue-row.failed { border-color: var(--hot); }
.queue-row.failed .q-status { color: var(--hot); }
.reload-note {
  color: rgb(243, 182, 182);
  font-weight: bold;
  background-color: #000;
  border: 2px groove var(--cyan);
  padding: 5px;
  text-align: center;
}

/* ----------------------------------------------------------------- grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .8rem;
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

.tile {
  margin: 0;
  background-color: #0d0d0d;
  border: 4px ridge gray;
  overflow: hidden;
}
.tile:hover { border-color: var(--cyan); }
.tile-open {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: #000;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  text-transform: none;
}
.tile-open:hover { background: #000; }
.tile-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--cyan);
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: .1em;
  background-color: var(--well);
}
.placeholder::after { content: attr(data-ext); }

.badge.play {
  position: absolute;
  left: .4rem;
  bottom: .4rem;
  background: #000;
  color: var(--cyan);
  border: 2px groove var(--cyan);
  padding: .1rem .4rem;
  font-size: .7rem;
  font-weight: bold;
}

.tile figcaption {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .5rem;
  font-size: .75rem;
  background-color: #000;
  border-top: 2px groove var(--cyan);
}
.tile .who {
  font-weight: bold;
  color: var(--cyan);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .when { color: var(--ink-soft); white-space: nowrap; }

/* ------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .96);
  display: grid;
  grid-template-rows: 1fr auto;
}
.lightbox[hidden] { display: none; }

.lb-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
/* Fill the stage in both directions rather than sitting at native size in the
   middle of a big desktop window; object-fit keeps the aspect ratio, so
   whichever dimension runs out first is the one that bounds it.
   Absolute positioning is what makes this work: a percentage height on a
   centred grid item does not resolve against the grid area, so the image
   would size itself from its aspect ratio and overflow the stage. */
.lb-stage img, .lb-stage video {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: calc(100% - 2rem);
  height: calc(100% - 2rem);
  object-fit: contain;
}
.lb-file { text-align: center; }

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
  background-color: var(--magenta);
  color: #ffffff;
  font-size: .8rem;
  border-top: 5px double #000000;
}

.lb-close, .lb-nav {
  position: absolute;
  z-index: 2;
  font-family: var(--mono);
  font-weight: bold;
  background-color: var(--deep);
  color: var(--ink);
  border: 3px outset #ffebeb;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: .4rem .7rem;
}
.lb-close:hover, .lb-nav:hover { background-color: var(--magenta); color: #fff; }
.lb-close { top: .8rem; right: .8rem; }
.lb-nav { top: 50%; transform: translateY(-50%); }
.lb-nav.prev { left: .6rem; }
.lb-nav.next { right: .6rem; }

/* ---------------------------------------------------------------- admin */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  background-color: var(--well);
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: .45rem .5rem;
  border-bottom: 2px groove var(--cyan);
  vertical-align: middle;
}
.admin-table th { text-transform: uppercase; color: var(--cyan); }
.admin-table img { width: 56px; height: 56px; object-fit: cover; display: block; }
.admin-actions { display: flex; gap: .8rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.notice {
  margin: 1rem auto;
  max-width: 1200px;
  padding: 5px;
  background-color: #000;
  border: 2px groove var(--cyan);
  color: rgb(243, 182, 182);
  font-weight: bold;
  text-align: center;
}
