/* ===== App additions on top of 01 styles: login · admin · slideshow ===== */

/* Login */
.login { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 1.25rem; }
.login-card { width: min(100%, 360px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem 1.8rem 1.9rem; text-align: center; }
.login-mono { width: 3rem; height: 3rem; margin: 0 auto 1rem; border: 1.5px solid var(--accent); color: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--slab); font-weight: 700; }
.login-card h1 { font-family: var(--slab); font-weight: 700; font-size: 1.8rem; margin: 0 0 .3rem; }
.login-card p { color: var(--ink-soft); margin: 0 0 1.4rem; font-size: .98rem; }
.login-card input { width: 100%; height: 52px; padding: 0 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 1.05rem; margin-bottom: .9rem; text-align: center; }
.login-card input:focus { outline: none; border-color: var(--accent); }

/* password field + show/hide toggle */
.pw-wrap { position: relative; margin-bottom: .9rem; }
.login-card .pw-wrap input { margin-bottom: 0; padding-left: 3rem; padding-right: 3rem; }
.pw-toggle { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-soft); display: grid; place-items: center; border-radius: 10px; cursor: pointer; transition: color .2s, background .2s; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); outline: none; }
.pw-toggle svg { width: 20px; height: 20px; }
.login-card .btn { width: 100%; }
.login-err { color: var(--accent); font-size: .92rem; min-height: 1.2em; margin-top: .6rem; }

/* Login: rotating photo backdrop */
.login { position: relative; overflow: hidden; }
.login-card { position: relative; z-index: 2; }
.login-bg { position: absolute; inset: 0; z-index: 0; }
.login-bg-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 1.5s ease; will-change: opacity; }
.login-bg-layer.show { opacity: 1; }
.login-bg-ken { position: absolute; inset: 0; background-size: cover; background-position: center; transform: scale(1.03); }
.login-bg-layer.show .login-bg-ken { animation: kenburns 9s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1.03); } to { transform: scale(1.13); } }
.login.has-bg::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(125% 95% at 50% 28%, rgba(28,18,10,.26), rgba(18,11,6,.66) 78%), linear-gradient(to top, rgba(18,11,6,.7), rgba(18,11,6,.16)); }
.login.has-bg .login-card { background: color-mix(in srgb, var(--card) 86%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.08); backdrop-filter: blur(16px) saturate(1.08);
  border-color: color-mix(in srgb, var(--line) 55%, transparent); box-shadow: 0 26px 72px rgba(12,7,3,.52); }

/* Topbar right cluster + admin controls */
.topbar .right { display: flex; align-items: center; gap: .5rem; }
.adminflag { font-family: var(--sans); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: .25rem .55rem; }
.btn-sm { display: inline-flex; align-items: center; gap: .4rem; height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-family: var(--sans); font-weight: 500; font-size: .9rem; cursor: pointer; transition: border-color .2s, transform .2s; text-decoration: none; }
.btn-sm:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn-sm.primary { background: var(--accent); color: #FBF3E8; border-color: var(--accent); }
.btn-sm svg { width: 18px; height: 18px; }

/* Album admin toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 0 0 1.4rem; }
.toolbar select { height: 44px; border: 1px solid var(--line); border-radius: 999px; background-color: var(--card); color: var(--ink); padding: 0 2.1rem 0 1rem; font-family: var(--sans); font-size: .9rem; appearance: none; -webkit-appearance: none; background-repeat: no-repeat; background-position: right .85rem center; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236E6052' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] .toolbar select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23B3A491' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
.toolbar .spacer { flex: 1; }
.hint { color: var(--ink-soft); font-size: .85rem; }

/* Per-photo admin overlay */
.cell .ph-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; z-index: 3; }
.cell:hover .ph-actions, .cell:focus-within .ph-actions { opacity: 1; }
.ph-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: rgba(33, 22, 12, .62); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(4px); }
.ph-btn:hover { background: var(--accent); }
.ph-btn svg { width: 17px; height: 17px; }
.ph-btn.is-cover { background: var(--accent); }
.ph-btn.is-login { background: var(--accent); }
.cell.dragging { opacity: .35; }
.cell.dragover { outline: 3px solid var(--accent); outline-offset: -3px; }
.admin .cell { cursor: pointer; }

/* Slideshow progress bar (reuses .lb) */
.lb-progress { position: absolute; top: 0; left: 0; height: 3px; background: var(--accent); width: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 80; background: rgba(33, 22, 12, .92); color: #FBF3E8; padding: .7rem 1.2rem; border-radius: 999px; font-size: .92rem; font-family: var(--sans); opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* lightbox chrome: top band (tools · centred caption · close) + bottom speed pill */
.lb-top { position: absolute; top: 0; left: 0; right: 0; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem;
  padding: max(.7rem, env(safe-area-inset-top)) max(.8rem, 2vw) 1.5rem;
  background: linear-gradient(to bottom, rgba(18,11,6,.62), rgba(18,11,6,0)); pointer-events: none; }
.lb-top .lb-btn, .lb-top .lb-grp { pointer-events: auto; }
.lb-top .lb-btn { position: static; transform: none; }
.lb-top .lb-btn:hover { transform: scale(1.05); }
.lb-grp { display: flex; align-items: center; gap: .5rem; }
.lb-cap2 { position: absolute; left: 50%; transform: translateX(-50%); top: max(.85rem, env(safe-area-inset-top)); max-width: 56%; text-align: center; pointer-events: none; }
.lb-album { font-family: var(--slab); font-weight: 600; font-size: 1.05rem; color: #F6ECDE; text-shadow: 0 1px 10px rgba(0,0,0,.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-meta { display: flex; gap: .6rem; justify-content: center; align-items: baseline; margin-top: .15rem; }
.lb-counter { font-family: var(--slab); font-variant-numeric: tabular-nums; color: #E0A78F; font-size: .82rem; letter-spacing: .14em; text-shadow: 0 1px 6px rgba(0,0,0,.65); }
.lb-date { color: #F0E3D4; font-size: .82rem; text-shadow: 0 1px 6px rgba(0,0,0,.65); }
.lb-speed { position: absolute; bottom: max(1rem, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 4;
  display: inline-flex; align-items: center; gap: .3rem; background: rgba(30,22,14,.62); border: 1px solid rgba(243,194,166,.28); border-radius: 999px;
  padding: .2rem .45rem; color: #F4E8DA; font-family: var(--sans); font-size: .92rem; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.lb-speed[hidden] { display: none; }
.lb-sp { width: 36px; height: 36px; border: none; background: transparent; color: #F4E8DA; font-size: 1.3rem; line-height: 1; cursor: pointer; border-radius: 50%; }
.lb-sp:hover { background: rgba(70,44,26,.85); }
.lb-sp-val { min-width: 2.6em; text-align: center; font-variant-numeric: tabular-nums; }

/* floating "back to top" — upper-right, fades in after scrolling down */
.to-top { position: fixed; top: calc(env(safe-area-inset-top) + 4.6rem); right: clamp(1rem, 4vw, 3rem); z-index: 40;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(-8px) scale(.92); pointer-events: none; transition: opacity .3s, transform .3s, border-color .2s; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); transform: translateY(-2px); }
.to-top svg { width: 22px; height: 22px; }

/* ===== Polish: reveal · view enter · motion · mobile ===== */
* { -webkit-tap-highlight-color: transparent; }

/* scroll-reveal for album cards (replaces all-at-once rise) */
.album-card { opacity: 1; transform: none; animation: none; }
.reveal { opacity: 0; transform: translateY(20px); transition: opacity .65s cubic-bezier(.2,.7,.2,1), transform .65s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* soft per-view enter */
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-enter { animation: viewIn .45s cubic-bezier(.2,.7,.2,1) both; }

/* lightbox: gentle fade + zoom on open and each slide */
.lb-stage { opacity: 0; transform: scale(.985); transition: opacity .34s ease, transform .34s cubic-bezier(.2,.7,.2,1); }
.lb-stage.shown { opacity: 1; transform: none; }
.lb-stage img { opacity: 1; }

/* tactile press */
.btn:active, .btn-sm:active, .ph-btn:active, .album-card:active, .cell:active { transform: scale(.985); }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .topbar { padding: .6rem .85rem; }
  .brand { font-size: 1.1rem; gap: .4rem; }
  .topbar .right { gap: .35rem; }
  .btn-sm { height: 42px; padding: 0 .8rem; font-size: .86rem; }
  .toolbar { gap: .5rem; }
  .toolbar .spacer { display: none; }
  .lb-top { padding: max(.6rem, env(safe-area-inset-top)) .7rem 1.3rem; }
  .lb-prev, .lb-next { width: 46px; height: 46px; }
  .lb-cap2 { max-width: 52%; }
  .lb-album { font-size: .9rem; }
  .lb-date { display: none; }
  .to-top { width: 42px; height: 42px; top: calc(env(safe-area-inset-top) + 4rem); }
  .login-card { padding: 1.8rem 1.35rem 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.in { opacity: 1 !important; transform: none !important; transition: none !important; }
  .view-enter { animation: none !important; }
  .lb-stage { opacity: 1 !important; transform: none !important; transition: none !important; }
  .login-bg-layer { transition: none !important; }
  .login-bg-layer.show .login-bg-ken { animation: none !important; transform: none !important; }
}

/* LQIP: tiny inline placeholder fills the cell/cover behind the image as it fades in */
.cell, .album-cover { background-size: cover; background-position: center; background-repeat: no-repeat; }

/* No accidental text selection / copy / image-drag — smoother dragging + mobile feel */
#app { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#app input, #app textarea { -webkit-user-select: text; user-select: text; }
#app img { -webkit-user-drag: none; user-drag: none; }

/* Album drag-reorder */
.album-card.dragging { box-shadow: 0 26px 64px -18px rgba(0,0,0,.5); opacity: .97; cursor: grabbing; }
.album-placeholder { border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 7%, transparent); }
body.reordering { cursor: grabbing; }
