/* Layout: a sunny gallery wall in the studio's own colours. Big friendly name, collection grid,
   then one collection at a time: main piece large, the rest in a masonry. */
:root {
  --bg: #fbfaf6;
  --surface: #eef0fd;
  --card: #ffffff;
  --ink: #1e1a4d;
  --muted: #66658a;
  --line: #e2e3f2;
  --accent: #5f6fe8;
  --sun: #f6d14a;
  --on-sun: #1e1a4d;
  --danger: #c2413a;
  --live: #3faa6e;
  --scrim: rgba(18, 17, 42, .95);
  --scrim-ink: #f3f1ff;
  --scrim-muted: #b4b3d4;
  --shadow: 0 1px 2px rgba(30, 26, 77, .06), 0 14px 34px -14px rgba(30, 26, 77, .22);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1320px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12112a; --surface: #1c1b3a; --card: #1a1936; --ink: #f3f1ff; --muted: #a6a5c6;
    --line: #2b2a4f; --accent: #a3adff; --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 14px 34px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.wrap {
  width: 100%; max-width: var(--max); margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px), 4vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 4vw);
}
main { flex: 1; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand span { font: 600 20px/1.1 var(--display); }
.logo { flex: none; width: 48px; height: 48px; object-fit: contain; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
.navlink, .linkish {
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted);
  font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
}
.navlink:hover, .linkish:hover { color: var(--accent); }
.linkish { margin-left: 10px; letter-spacing: .04em; text-transform: none; text-decoration: underline; text-underline-offset: 3px; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.on i { background: var(--live); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 50%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
.chip { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); border: 1px solid currentColor; border-radius: 99px; padding: 3px 9px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 99px; padding: 9px 18px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 500;
  transition: border-color .2s, background .2s, transform .2s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--sun); color: var(--on-sun); border-color: var(--sun); }
.btn.primary:hover { transform: translateY(-1px); border-color: var(--on-sun); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: progress; transform: none; }

.view { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { opacity: .001; transform: translateY(12px); } }

/* ---- home ---- */
.intro { display: grid; gap: 28px; justify-items: start; padding-block: clamp(44px, 10vw, 120px) clamp(36px, 6vw, 76px); max-width: 960px; }
.intro .logo { width: clamp(120px, 17vw, 176px); height: auto; aspect-ratio: 1; filter: drop-shadow(0 10px 22px rgba(30, 26, 77, .18)); transform: rotate(-4deg); }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.intro h1 { margin: 0; font: 600 clamp(46px, 9vw, 108px)/.95 var(--display); letter-spacing: -.025em; text-wrap: balance; }
.intro h1 em { font-style: italic; font-weight: 500; color: var(--accent); }
.tagline { margin: 0; font: italic 400 clamp(19px, 2.3vw, 26px)/1.4 var(--display); color: var(--muted); max-width: 34ch; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 32px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font: 600 28px/1.1 var(--display); }
.section-head span { font-size: 13px; color: var(--muted); }

/* Storage meter (signed-in artist only) */
.storage { margin: -12px 0 32px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.storage-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; }
.storage-top strong { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.storage-top span { font-size: 14px; font-variant-numeric: tabular-nums; }
.storage-bar { height: 8px; margin: 10px 0 8px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.storage-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.storage p { margin: 0; font-size: 13px; color: var(--muted); }
.storage.warn .storage-bar i { background: var(--danger); }
.storage.warn .storage-top strong { color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 52px 32px; padding-bottom: 96px; }
.card { display: block; }
.card .frame { aspect-ratio: 1; max-width: 100%; border-radius: 6px; box-shadow: var(--shadow); }
.card .frame img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .frame img { transform: scale(1.04); }
.card-body { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-top: 16px; }
.card h3 { margin: 0; font: 600 22px/1.2 var(--display); min-width: 0; overflow-wrap: anywhere; }
.card p { margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; }
.badge {
  position: absolute; top: 14px; left: 14px; z-index: 2; padding: 5px 10px; border-radius: 99px;
  background: var(--sun); color: var(--on-sun); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}

/* ---- frames & loading ---- */
.frame { position: relative; overflow: hidden; background: var(--surface); }
.frame img { opacity: 0; transition: opacity .6s ease, transform 1.1s cubic-bezier(.2, .7, .2, 1); }
.frame.ready img { opacity: 1; }
.frame:not(.ready)::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--card) 70%, transparent) 50%, transparent 80%);
  background-size: 200% 100%; animation: shimmer 1.6s infinite linear;
}
.frame.failed::after { animation: none; background: none; }
.frame.failed::before { content: "Couldn't load this piece"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* ---- collection ---- */
.back { display: inline-block; margin-top: 32px; font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.back:hover { color: var(--accent); }
.col-head { padding-block: clamp(24px, 5vw, 52px) clamp(20px, 3vw, 32px); display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; }
.col-head h1 { margin: 0; font: 600 clamp(38px, 7vw, 80px)/1 var(--display); letter-spacing: -.02em; text-wrap: balance; overflow-wrap: anywhere; min-width: 0; }
.col-head p { margin: 0; font-size: 13px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }

.hero { margin: 0 0 clamp(44px, 8vw, 92px); padding: clamp(16px, 4vw, 56px); background: var(--surface); border-radius: 10px; }
.hero .open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.hero .frame { background: transparent; min-height: 320px; display: grid; place-items: center; }
.hero .frame.ready { min-height: 0; }
.hero img { max-height: 76vh; width: auto; margin: 0 auto; box-shadow: var(--shadow); }

.works-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-bottom: 16px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.works-head h2 { margin: 0; font: 600 26px/1.1 var(--display); }
.works-head span { font-size: 13px; color: var(--muted); }
/* Pieces are dealt left to right into columns, so the order reads across like a page. */
.masonry { display: flex; align-items: flex-start; gap: 24px; padding-bottom: 96px; }
.masonry-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.tile { position: relative; margin: 0; }
.order-hint { margin: -12px 0 22px; font-size: 13px; color: var(--muted); }

/* drag to reorder (editors) */
.tile[draggable="true"] .open { cursor: grab; }
.tile.dragging { opacity: .35; }
.tile.drop-before::before, .tile.drop-after::after {
  content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: var(--accent); z-index: 3;
}
.tile.drop-before::before { top: -14px; }
.tile.drop-after::after { bottom: -14px; }
.order-num {
  position: absolute; top: 10px; left: 10px; z-index: 2; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 99px;
  display: grid; place-items: center; background: var(--sun); color: var(--on-sun); font-size: 12px; font-weight: 600; pointer-events: none;
}
.tile .open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.tile .frame { border-radius: 4px; box-shadow: var(--shadow); }
.tile .frame:not(.ready) { aspect-ratio: 1; }
.tile img { width: 100%; height: auto; }
.tile .open:hover img { transform: scale(1.025); }
.piece-tools { display: flex; gap: 14px; justify-content: center; padding-top: 10px; }
.piece-tools button { background: none; border: 0; padding: 2px 0; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--muted); }
.piece-tools button:hover { color: var(--accent); }
.piece-tools button.rm:hover { color: var(--danger); }
.piece-tools button:disabled { opacity: .3; cursor: default; color: var(--muted); }

.empty { display: grid; justify-items: center; gap: 14px; padding-block: 72px 120px; text-align: center; }
.empty h2 { margin: 0; font: 600 30px/1.2 var(--display); }
.empty p { margin: 0; color: var(--muted); max-width: 44ch; }

/* ---- footer ---- */
.footer { border-top: 1px solid var(--line); font-size: 13px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding-block: 28px 36px; }
.footer p { margin: 0; }
.footer .muted { color: var(--muted); }

/* ---- lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; align-items: center;
  background: var(--scrim); color: var(--scrim-ink); animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } }
.lb-stage { margin: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-block: 56px 24px; min-width: 0; }
.lb-img-wrap { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
.lb-img-wrap img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; transition: opacity .3s; }
.lb-img-wrap img.loading { opacity: .25; }
.lb-meta { display: flex; gap: 18px; margin-top: 16px; font-size: 13px; color: var(--scrim-muted); }
.lb-caption { font: italic 400 17px var(--display); color: var(--scrim-ink); }
.lb-btn {
  width: 48px; height: 48px; justify-self: center; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .05); color: var(--scrim-ink);
  font: 300 28px/1 var(--sans); cursor: pointer; display: grid; place-items: center; padding: 0 0 3px;
}
.lb-btn:hover { background: rgba(255, 255, 255, .14); }
.lb-close { position: absolute; top: 14px; right: 14px; }

/* ---- sheets (sign in, editing) ---- */
.sheet-back {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--ink) 45%, transparent); animation: fade .2s ease;
}
.sheet {
  width: min(560px, 100%); max-height: 100%; overflow: auto; display: grid; gap: 20px;
  background: var(--card); color: var(--ink); border-radius: 14px; padding: clamp(20px, 4vw, 32px); box-shadow: var(--shadow);
}
.sheet h2 { margin: 0; font: 600 28px/1.15 var(--display); }
.sheet p { margin: 0; color: var(--muted); }
.sheet .logo { width: 72px; height: 72px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input[type="text"], .field input[type="email"], .field input[type="password"] {
  padding: 11px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
}
.field input:focus { outline: none; border-color: var(--accent); }
.drop {
  position: relative; display: grid; place-items: center; gap: 4px; padding: 18px; border-radius: 10px; text-align: center; cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--surface); font-size: 14px;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { color: var(--accent); font-weight: 600; }
.drop small { color: var(--muted); font-size: 12px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs span { font-size: 12px; background: var(--surface); border-radius: 6px; padding: 4px 8px; max-width: 100%; overflow-wrap: anywhere; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--muted); min-height: 1.6em; }
.status.err { color: var(--danger); }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 11px 20px; border-radius: 99px; background: var(--ink); color: var(--bg);
  font-size: 13px; box-shadow: var(--shadow); transition: opacity .35s, transform .35s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .brand span { font-size: 17px; }
  .navlink, .live { display: none; }
  .lightbox { grid-template-columns: minmax(0, 1fr); }
  .lb-prev, .lb-next { position: absolute; bottom: 20px; }
  .lb-prev { left: calc(50% - 60px); }
  .lb-next { right: calc(50% - 60px); }
  .lb-stage { padding-bottom: 90px; }
  .lb-img-wrap img { max-height: calc(100vh - 200px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
