/*
 * Shared stylesheet for BOTH entry points — the authenticated app
 * (index.html → start) and the anonymous public-folder viewer
 * (public.html → startPublic). The public viewer renders a strict subset of
 * the app's components (tiles, folder rows, the overlay/popup, the expander),
 * so one stylesheet covers both and they can no longer drift. Uploaded to the
 * website bucket by terraform/frontend.tf.
 */

/* ---- Design tokens (light) ---------------------------------------- */
:root {
  --bg: #eceef4;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --text: #1a1d26;
  --text-muted: #6b7280;
  --border: #e5e8f0;
  --border-strong: #d3d8e3;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-weak: rgba(99, 102, 241, .12);
  --danger: #e5484d;
  --green: #12a05f;
  --purple: #8b5cf6;
  --orange: #ea8a08;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 10px 28px -14px rgba(16,24,40,.22);
  --shadow-lift: 0 10px 22px -8px rgba(16,24,40,.32);
}
/* ---- Design tokens (dark) ----------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e15;
    --surface: #161a24;
    --surface-2: #1e2330;
    --text: #e7e9f0;
    --text-muted: #98a0b3;
    --border: #262c3a;
    --border-strong: #343c4e;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-weak: rgba(129, 140, 248, .16);
    --danger: #f2555a;
    --green: #34d399;
    --purple: #a78bfa;
    --orange: #fbbf24;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -16px rgba(0,0,0,.75);
    --shadow-lift: 0 14px 28px -10px rgba(0,0,0,.8);
  }
}

*, *::before, *::after { box-sizing: border-box; }
::selection { background: var(--accent-weak); }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 2.5rem 1.5rem;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 520px at 100% -10%, var(--accent-weak), transparent 60%),
    var(--bg);
  background-attachment: scroll;
}
#app { max-width: 64rem; margin: 0 auto; }
@media (max-width: 640px) { body { padding: 1.25rem 1rem; } }

h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.025em;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Controls ------------------------------------------------------ */
input, button { font: inherit; }
button {
  padding: .42rem .8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, color .12s ease, background .12s ease;
}
button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
button:active { transform: translateY(0); box-shadow: none; }
button:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; border-color: var(--border-strong); color: var(--text); }
input {
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* Primary calls to action: filled accent gradient. */
.newfolder button, .undo {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
}
.newfolder button:hover, .undo:hover:not(:disabled) { color: #fff; filter: brightness(1.08); border: none; }

.linkish { background: none; border: none; color: var(--accent); cursor: pointer; text-align: left; padding: 0; }
.linkish:hover { text-decoration: underline; transform: none; box-shadow: none; color: var(--accent); }

.login {
  display: flex; flex-direction: column; gap: .7rem; max-width: 23rem;
  background: var(--surface); padding: 1.6rem; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
/* The admin page reuses .login's card styling but needs more width, since
   each section lays its controls out in a row (.adminrow) rather than
   stacking every input on its own line. */
.login.admin { max-width: 46rem; }
.adminrow { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.adminrow input, .adminrow select { flex: 1 1 12rem; }
.pwbox { display: flex; align-items: center; gap: .25rem; }
.pwbox input { flex: 1; }
.hint { color: var(--text-muted); font-size: .85rem; margin: -.3rem 0 .2rem; }
.eye { background: none; border: none; cursor: pointer; padding: 0 .3rem; font-size: 1rem; }
.eye:hover { transform: none; box-shadow: none; border: none; }

.empty { color: var(--text-muted); font-style: italic; font-size: .9rem; }
/* Status/error banner: fixed to the top of the viewport, above everything,
   so it can't be missed or scrolled past. Dismissible by click or Escape. */
.status-popup {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 20; max-width: 90vw; min-width: 20rem;
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.75rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--green);
  box-shadow: var(--shadow-lift); cursor: pointer;
  color: var(--green); font-size: 1.15rem;
}
.status-popup.error { border-color: var(--danger); color: var(--danger); }
.status-popup .status-text { flex: 1; overflow-wrap: anywhere; }
.status-popup .status-close {
  border: none; background: none; cursor: pointer; padding: 0 .2rem;
  font-size: 1.5rem; line-height: 1; color: inherit; opacity: .7;
}
.status-popup .status-close:hover, .status-popup .status-close:focus-visible { opacity: 1; transform: none; box-shadow: none; border: none; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.newfolder { display: inline-flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.publicmode { display: flex; align-items: center; gap: .3rem; user-select: none; font-size: .9rem; color: var(--green); }
ul { list-style: none; padding: 0; margin: 0; }

/* ---- Section cards ------------------------------------------------- */
.area {
  margin-top: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: var(--shadow);
}
.area > h3 {
  margin: .2rem 0 .5rem;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em;
  display: flex; align-items: center; gap: .5rem;
  padding-bottom: .6rem; border-bottom: 1px solid var(--border);
}
/* Folders shared with me: read-only, so no drag affordances. */
.shared-area > h3 { color: var(--purple); }
/* Groups: full read-write for every member, like co-owned folders. */
.groups-area > h3 { color: var(--accent); }
.manage-members { margin: .4rem 0 .6rem 1.9rem; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.manage-members ul { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .5rem; }
.manage-members li { display: flex; align-items: center; gap: .5rem; }

/* ---- Folder rows --------------------------------------------------- */
.folder { padding: .1rem 0; }
.folder-row {
  display: flex; gap: .5rem; align-items: center;
  padding: .4rem .5rem;
  border-radius: var(--radius-sm);
  transition: background .12s ease;
}
.folder:not(:last-child) > .folder-row { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.folder-row:hover { background: var(--surface-2); }
.folder-row.dragover, h3.dragover {
  background: var(--accent-weak);
  outline: 2px dashed var(--accent); outline-offset: -2px;
  border-radius: var(--radius-sm);
}
/* Public folders: tinted rows, 🌐 instead of 📁. */
.folder-row.public { background: rgba(18, 160, 95, .09); }
.folder-row.public:hover { background: rgba(18, 160, 95, .16); }
.folder-row.public .name::before { content: "🌐 "; }
.folder-row.shared .name::before { content: "👥 "; }
.folder-row .name { flex: 1; font-weight: 600; }
.folder-row .name::before { content: "📁 "; }
/* A group itself (as opposed to a folder inside one): tinted row, accent
   color, 🧑‍🤝‍🧑 instead of 📁 — so it reads as a different kind of thing
   than the folders nested beneath it, which stay plain folder rows. */
.folder-row.group { background: var(--accent-weak); }
.folder-row.group:hover { background: color-mix(in srgb, var(--accent-weak) 65%, var(--accent) 15%); }
.folder-row.group .name { color: var(--accent); }
.folder-row.group .name::before { content: "🧑‍🤝‍🧑 "; }
.folder-row .owner { color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.expander { width: 2rem; border: none; background: none; color: var(--text-muted); font-size: .8rem; }
.expander:hover { transform: none; box-shadow: none; border: none; color: var(--accent); background: var(--accent-weak); }
/* Compact icon buttons (refresh) beside a folder row or section heading. */
button.refresh { padding: .2rem .5rem; font-size: 1.25rem; font-weight: 700; line-height: 1; }
button.refresh:hover, button.refresh:focus-visible { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); transform: none; box-shadow: none; }
h3 button.refresh { font-size: 1.1rem; margin-left: auto; }
/* Compact trash-icon button (e.g. deleting a group), same footprint as
   .refresh but tints red on hover to signal a destructive action. */
button.trash { border: none; background: none; cursor: pointer; padding: 0 .3rem; font-size: .95rem; opacity: .55; }
button.trash:hover, button.trash:focus-visible { opacity: 1; transform: none; box-shadow: none; border: none; background: rgba(220, 38, 38, .14); }
.folder-body { margin-left: 1rem; border-left: 2px solid var(--border); padding: .35rem 0 .5rem 1rem; }

/* ---- Photo tiles --------------------------------------------------- */
.grid { display: flex; flex-wrap: wrap; gap: 1rem; margin: .75rem 0; }
.tile { width: 120px; position: relative; cursor: grab; transition: transform .18s ease; }
.tile:hover { transform: translateY(-4px); }
.tile.shared { cursor: default; }
.tile img.thumb {
  width: 120px; height: 120px; object-fit: cover;
  border-radius: 12px; cursor: pointer; display: block;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, outline-color .12s ease;
}
.tile:hover img.thumb { box-shadow: var(--shadow-lift); }
.tile.reorder-over img.thumb { outline: 2px dashed var(--accent); outline-offset: 2px; }
.playbadge { position: absolute; top: 44px; left: 48px; font-size: 1.4rem; color: #fff; text-shadow: 0 0 6px rgba(0,0,0,.8); pointer-events: none; }
.tile-bar { display: flex; justify-content: space-between; align-items: center; font-size: .72rem; gap: .25rem; margin-top: .4rem; color: var(--text-muted); }
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.tile-name:hover { color: var(--accent); text-decoration: underline; }
.tile-name.readonly { cursor: default; }
.tile-name.readonly:hover { color: inherit; text-decoration: none; }

/* ---- Fullscreen popup ---------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 16, .8);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.overlay img.full, .overlay video.full { max-width: 92vw; max-height: 92vh; border-radius: 12px; box-shadow: 0 24px 64px -16px rgba(0,0,0,.75); }
.overlay .popup-caption {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1;
  padding: 1rem 5rem; text-align: center;
  font-size: 1.1rem; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6);
  background: linear-gradient(rgba(8,10,16,.7), transparent);
  pointer-events: none;
}
/* Move-or-copy drop prompt: a small card, not the fullscreen media viewer. */
.transfer-prompt {
  cursor: default; max-width: 24rem; padding: 1.25rem 1.5rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column; gap: .9rem;
}
.transfer-prompt p { margin: 0; overflow-wrap: anywhere; }
.transfer-prompt-buttons { display: flex; gap: .5rem; }
.transfer-prompt label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-muted); user-select: none; }
/* Prev/next navigation arrows over the full-size media. */
.overlay .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 3rem; height: 3rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; line-height: 1; color: #fff;
  background: rgba(18, 20, 28, .55); border: 1px solid rgba(255,255,255,.25);
  border-radius: 50%; cursor: pointer; user-select: none;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.overlay .nav.prev { left: 1.25rem; }
.overlay .nav.next { right: 1.25rem; }
.overlay .nav:hover { background: rgba(18, 20, 28, .9); color: #fff; border-color: rgba(255,255,255,.55); transform: translateY(-50%) scale(1.08); box-shadow: none; }
@media (max-width: 640px) { .overlay .nav { width: 2.5rem; height: 2.5rem; font-size: 1.6rem; } .overlay .nav.prev { left: .4rem; } .overlay .nav.next { right: .4rem; } }
/* Delete button over the full-size photo (read-write folders only). */
.overlay .popup-delete {
  position: absolute; top: 1.25rem; right: 1.25rem;
  width: 3rem; height: 3rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1;
  background: rgba(18, 20, 28, .55); border: 1px solid rgba(255,255,255,.25);
  border-radius: 50%; cursor: pointer; user-select: none;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.overlay .popup-delete:hover { background: rgba(150, 30, 30, .9); border-color: rgba(255,255,255,.55); transform: scale(1.08); }
@media (max-width: 640px) { .overlay .popup-delete { width: 2.5rem; height: 2.5rem; font-size: 1.3rem; top: .4rem; right: .4rem; } }
/* Visual-only rotate buttons (top-left): turn the shown image in the
   browser; nothing is saved. */
.overlay .popup-rotate {
  position: absolute; top: 1.25rem;
  width: 3rem; height: 3rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1; color: #fff;
  background: rgba(18, 20, 28, .55); border: 1px solid rgba(255,255,255,.25);
  border-radius: 50%; cursor: pointer; user-select: none;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
/* Stacked vertically at the top-left so neither sits over the image. */
.overlay .popup-rotate.ccw { left: 1.25rem; top: 1.25rem; }
.overlay .popup-rotate.cw  { left: 1.25rem; top: 4.75rem; }
.overlay .popup-rotate:hover { background: rgba(18, 20, 28, .9); border-color: rgba(255,255,255,.55); transform: scale(1.08); }
@media (max-width: 640px) {
  .overlay .popup-rotate { width: 2.5rem; height: 2.5rem; font-size: 1.3rem; }
  .overlay .popup-rotate.ccw { left: .4rem; top: .4rem; }
  .overlay .popup-rotate.cw  { left: .4rem; top: 3.3rem; }
}
