/* Portfolio-For-Friends
 *
 * Visual language deliberately inherited from ../styles-gallery — same dark gallery
 * room, warm gold placard accent, Fraunces + Hanken Grotesk, film grain over black.
 * Keep the tokens below in sync with that project if it evolves.
 */

:root {
  --bg: #08080a;           /* deep dark-room black */
  --bg-soft: #121217;
  --panel: #141319;
  --line: #26262e;
  --text: #efece8;
  /* Contrast against --bg, which is near-black. The original --dim/--faint pair
     measured ~7:1 and ~3.8:1; the latter failed WCAG AA (4.5:1) and carried most of
     the 11px text, which is exactly the worst combination. Raised to ~9.5:1 and
     ~6.2:1 — still clearly secondary, but legible. */
  --dim: #b5b2be;
  --faint: #8f8c9b;
  --accent: #c9a96a;       /* warm gold — gallery placard */
  --accent-soft: #ecdcb6;
  --ember: #c87a3c;
  --radius: 14px;
  --maxw: 1500px;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ui: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

/* Any class that sets `display` beats the UA's `[hidden] { display: none }`, so an
   element with both stays visible. That silently broke the whole sign-in flow: the
   gate is `display: grid`, so hiding it did nothing and it covered the signed-in app.
   Assert it once, globally, rather than per-component. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* atmosphere — warm ember glow up top, heavy edge vignette: a dimly-lit room with
   the art catching the light. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(130% 80% at 50% -15%, rgba(200, 140, 70, 0.10), transparent 56%),
    radial-gradient(120% 90% at 50% 120%, rgba(0, 0, 0, 0.7), transparent 50%),
    radial-gradient(100% 100% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.45));
}
/* film grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: #1a1206; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, #0d0d11 86%, transparent);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
}
.top-row {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 28px 14px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.brand-mark {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  padding-right: 0.22em;
  background: linear-gradient(98deg, var(--accent-soft), var(--accent) 42%, var(--ember));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-tag {
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--dim);
  white-space: nowrap;
}

/* whose page you're on — the room you've walked into */
.page-owner {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-left: 8px;
  padding-left: 22px;
  border-left: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.page-owner-name {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.page-owner-count {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.search { position: relative; flex: 1 1 auto; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%;
  background: #101015;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px 10px 38px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color .16s, box-shadow .16s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; font-size: 14px;
}

/* ---------- notifications: "you have conversations on Betsy's page" ---------- */
.notices { max-width: var(--maxw); margin: 0 auto; padding: 22px 28px 0; display: grid; gap: 10px; }
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--accent) 9%, #101015);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: background .16s, border-color .16s;
}
.notice:hover {
  background: color-mix(in srgb, var(--accent) 14%, #101015);
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
}
.notice strong { color: var(--accent); font-weight: 600; }
.notice-when { font-size: 12px; color: var(--faint); white-space: nowrap; }

/* ---------- grid ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 30px 28px 70px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  background: #101015;
  border: 1px solid #24242c;
  border-radius: 14px;
  padding: 12px 12px 13px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease, background .22s ease;
}
/* Entry animation only on cards that are genuinely new — applying it to .card meant
   every repaint re-ran it for the whole grid. */
.card.enter { animation: riseIn .5s cubic-bezier(.2, .7, .2, 1) both; }
.card:hover {
  transform: translateY(-5px);
  background: #16161d;
  border-color: color-mix(in srgb, var(--accent) 55%, #24242c);
  box-shadow:
    0 22px 48px -20px rgba(0, 0, 0, 0.95),
    0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
    0 0 38px -10px color-mix(in srgb, var(--accent) 22%, transparent);
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.thumb {
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), 0 2px 6px rgba(0, 0, 0, .45);
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .6s cubic-bezier(.2, .6, .2, 1);
}
.card:hover .thumb img { transform: scale(1.06); }

.card-caption {
  font-size: 13px;
  line-height: 1.38;
  color: #cdcad6;
  margin: 11px 3px 1px;
  min-height: calc(1.34em * 2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* comment count doubles as the "there's conversation here" signal */
.card-meta {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 3px 0;
  font-size: 12px; color: var(--faint);
  letter-spacing: .4px; text-transform: uppercase;
}
.card-meta .has-unread { color: var(--accent); }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- usage meter (storage cap) ---------- */
.usage { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--faint);
         text-transform: uppercase; letter-spacing: .6px; }
.usage-bar { width: 90px; height: 4px; border-radius: 2px; background: #24242c; overflow: hidden; }
.usage-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ember)); }
.usage.near-cap .usage-fill { background: var(--ember); }

/* ---------- empty / states ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--faint);
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
}

@media (max-width: 720px) {
  .top-row { flex-wrap: wrap; gap: 14px; padding: 16px 18px 12px; }
  .search { max-width: none; order: 3; flex-basis: 100%; margin-left: 0; }
  .page-owner { margin-left: 0; padding-left: 0; border-left: none; }
  main, .notices { padding-left: 18px; padding-right: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}

/* ================================================================= buttons */
.btn {
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #101015;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, border-color .16s, transform .12s;
}
.btn:hover { background: #17171e; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(98deg, var(--accent-soft), var(--accent) 55%, var(--ember));
  color: #1a1206; border-color: transparent; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn.wide { width: 100%; padding: 11px; margin-top: 6px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

.linkish {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--accent); cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px;
}
.muted { color: var(--faint); font-size: 13px; }
em.muted { font-style: normal; }

/* ================================================================== fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--dim); letter-spacing: .3px; }
.field input, .field textarea {
  font: inherit; font-size: 14px;
  background: #0c0c11; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ============================================================== sign-in gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 380px;
  background: color-mix(in srgb, #101015 92%, transparent);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 30px 26px;
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.95);
}
.gate-card .brand-mark { font-size: 26px; }
.gate-card .brand-tag { margin-bottom: 26px; }
.gate-error {
  color: #e0806a; font-size: 13px; margin: 2px 0 10px;
  background: color-mix(in srgb, #e0806a 10%, transparent);
  border: 1px solid color-mix(in srgb, #e0806a 30%, transparent);
  border-radius: 8px; padding: 8px 11px;
}
.gate-switch { margin-top: 18px; font-size: 13px; color: var(--faint); text-align: center; }

/* ============================================================ header extras */
.brand { background: none; border: none; cursor: pointer; text-align: left; padding: 0; }
.top-actions { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }

/* ================================================================== modals */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4,4,6,.86);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn .18s ease both;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: 100%; max-width: 540px; max-height: 88dvh; overflow-y: auto;
  background: #101015; border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.95);
}
.modal-card h2 {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  margin-bottom: 6px;
}
.modal-close {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  background: none; border: none; color: var(--faint);
  font-size: 17px; cursor: pointer; padding: 6px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ================================================================ dropzone */
.dropzone {
  margin: 18px 0; padding: 34px 18px; text-align: center;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 13px; color: var(--dim); font-size: 14px; cursor: pointer;
  transition: background .16s, border-color .16s;
}
.dropzone:hover, .dropzone.over {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-color: var(--accent); color: var(--text);
}
.queue { list-style: none; margin-top: 14px; display: grid; gap: 7px; }
.queue li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12.5px; padding: 8px 11px;
  background: #0c0c11; border: 1px solid var(--line); border-radius: 9px;
}
.queue .st { color: var(--faint); text-transform: uppercase; letter-spacing: .5px; font-size: 12px; }
.queue .st.done { color: var(--accent); }
.queue .st.err { color: #e0806a; }
.queue .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================ lightbox */
.lightbox { padding: 0; }
.lb-body {
  display: grid; grid-template-columns: minmax(0,1fr) 340px;
  width: 100%; height: 100dvh;
}
.lb-image { display: grid; place-items: center; padding: 30px; min-width: 0; }
.lb-image img { max-width: 100%; max-height: calc(100dvh - 60px); border-radius: 10px; display: block; }
.lb-side {
  border-left: 1px solid var(--line); background: #0c0c11;
  display: flex; flex-direction: column; min-height: 0;
}
.lb-meta { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.lb-when-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 10px; }
.linkish.small { font-size: 12px; }
.lb-caption { font-size: 15px; margin-bottom: 8px; }
.lb-prompt {
  font-size: 13px; color: var(--dim); line-height: 1.5;
  max-height: 8.5em; overflow-y: auto; white-space: pre-wrap;
}
.lb-when { font-size: 12px; color: var(--faint); margin-top: 10px;
  text-transform: uppercase; letter-spacing: .5px; }
.lb-comments { flex: 1 1 auto; overflow-y: auto; padding: 12px 22px 16px; display: grid; gap: 14px; align-content: start; }
.cmt-who { font-size: 12px; color: var(--accent); font-weight: 600; }
.cmt-body { font-size: 13.5px; margin-top: 2px; white-space: pre-wrap; }
.cmt-when { font-size: 12px; color: var(--faint); margin-top: 3px; }

.lb-reply { display: flex; gap: 8px; padding: 16px 22px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.lb-reply input {
  flex: 1 1 auto; font: inherit; font-size: 13.5px;
  background: #101015; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
}
.lb-reply input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 3;
  background: rgba(16,16,21,.8); border: 1px solid var(--line); color: var(--text);
  width: 42px; height: 42px; border-radius: 50%; font-size: 22px; cursor: pointer;
}
.lb-nav:hover { border-color: var(--accent); }
.lb-nav.prev { left: 18px; }
.lb-nav.next { right: 374px; }

/* ================================================================= friends */
.add-friend { display: flex; gap: 8px; margin: 16px 0 12px; }
.add-friend input {
  flex: 1 1 auto; font: inherit; font-size: 14px;
  background: #0c0c11; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
}
.friend-list { list-style: none; display: grid; gap: 7px; }
.friend-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: #0c0c11;
  border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
}
.friend-list .handle { color: var(--faint); font-size: 12px; }
.friend-list .pending { color: var(--ember); font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px; }

/* =================================================================== toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; padding: 11px 18px; font-size: 13.5px;
  background: #16161d; color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 11px; box-shadow: 0 20px 40px -20px rgba(0,0,0,.9);
  animation: fadeIn .18s ease both;
}
.toast[hidden] { display: none; }

/* ============================================================== card badge */
.card-status {
  position: absolute; top: 18px; left: 18px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(10,10,14,.85); color: var(--ember);
  border: 1px solid color-mix(in srgb, var(--ember) 40%, transparent);
}
.card { position: relative; }

@media (max-width: 900px) {
  .lb-body { grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; height: 100dvh; }
  .lb-side { border-left: none; border-top: 1px solid var(--line); max-height: 46dvh; }
  .lb-image { padding: 16px; }
  .lb-nav.next { right: 18px; }
  .top-actions { flex-wrap: wrap; }
  .usage { display: none; }
}

.card-caption .untitled { color: var(--faint); font-style: italic; }

/* ---------------------------------------------------------- nsfw + editing */

/* Owner-declared only. The classifier's `rating` is advisory and currently absent —
   blurring on that would blur everything, since an unavailable scan writes no verdict. */
.thumb.nsfw img { filter: blur(22px) saturate(.7); transform: scale(1.1); }
.card:hover .thumb.nsfw img { transform: scale(1.1); }
.thumb { position: relative; }
.nsfw-badge {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-size: 11px; font-weight: 600; letter-spacing: .6px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(10,10,14,.85); color: var(--ember);
  border: 1px solid color-mix(in srgb, var(--ember) 45%, transparent);
}

.lb-edit .field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; margin: 4px 0 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.lb-actions { display: flex; gap: 8px; align-items: center; }
