/* ============================================================
   MotionPotion — app components (gallery, auth, account)
   Loads AFTER experience.css (uses its tokens + .btn/.nav).
   ============================================================ */

/* page scaffold for sub-pages */
.page {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(7rem, 12vw, 10rem) var(--gutter) clamp(3rem, 7vw, 6rem);
  min-height: 70vh;
}
.page-head { margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.8rem, 8vw, 6rem);
  letter-spacing: -0.035em;
  line-height: 0.92;
}
.page-head p { margin-top: 1rem; font-size: clamp(1rem, 1.5vw, 1.2rem); font-weight: 500; max-width: 54ch; }

/* ============================================================
   GALLERY
   ============================================================ */
.gallery {
  columns: 4 240px;
  column-gap: clamp(0.7rem, 1.6vw, 1.2rem);
  max-width: var(--maxw);
  margin-inline: auto;
}
.view-all-wrap { max-width: var(--maxw); margin-inline: auto; }

/* card + extrude trail wrapper */
.spell-card-wrap {
  position: relative;
  display: block;
  break-inside: avoid;
  margin-bottom: clamp(0.7rem, 1.6vw, 1.2rem);
}

.spell-card {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 2px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: var(--paper-pure);
  transition: transform 460ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.spell-card-wrap:hover .spell-card,
.spell-card-wrap:focus-within .spell-card { transform: translate(9px, -12px); }

/* colored extrude trails revealed underneath, staggered opacity */
.ex {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 16px;
  border: 2px solid var(--ink);
  opacity: 0;
  transform: translate(0, 0);
  transition: opacity 420ms var(--ease), transform 460ms cubic-bezier(0.22, 1, 0.36, 1);
}
.ex1 { background: var(--sky); z-index: 3; }      /* closest to card -> front */
.ex2 { background: var(--gold); z-index: 2; }
.ex3 { background: var(--flame); z-index: 1; }    /* furthest -> back */
.spell-card-wrap:hover .ex1,
.spell-card-wrap:focus-within .ex1 { opacity: 1; transform: translate(3px, -4px); transition-delay: 40ms; }
.spell-card-wrap:hover .ex2,
.spell-card-wrap:focus-within .ex2 { opacity: 1; transform: translate(-3px, 4px); transition-delay: 120ms; }
.spell-card-wrap:hover .ex3,
.spell-card-wrap:focus-within .ex3 { opacity: 1; transform: translate(-9px, 12px); transition-delay: 200ms; }

/* flat generated preview — aspect-ratio set per-card via inline style */
.spell-preview {
  position: relative;
  aspect-ratio: var(--ratio, 16 / 9);
  background: var(--bg, var(--ink));
  overflow: hidden;
  display: flex;
  align-items: center;
}
.spell-bars { display: grid; gap: 8px; width: 100%; padding: 0 14% 0 8%; }
.spell-bar { height: 11px; border-radius: 3px; background: var(--c, var(--flame)); transform-origin: left; }
.spell-card-wrap.is-visible .spell-bar { animation: barGrow 600ms var(--ease) both; }
.spell-card-wrap.is-visible .spell-bar:nth-child(2) { animation-delay: 80ms; }
.spell-card-wrap.is-visible .spell-bar:nth-child(3) { animation-delay: 160ms; }
.spell-card-wrap.is-visible .spell-bar:nth-child(4) { animation-delay: 240ms; }
.spell-card-wrap.is-visible .spell-bar:nth-child(5) { animation-delay: 320ms; }
.spell-card-wrap.is-visible .spell-bar:nth-child(6) { animation-delay: 400ms; }
@keyframes barGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.spell-shape {
  position: absolute;
  top: 12px; right: 14px;
  width: 26px; height: 26px;
  background: var(--c, var(--gold));
  z-index: 1;
}
.spell-shape.sq { border-radius: 6px; }
.spell-shape.circle { border-radius: 50%; }
.spell-shape.tri { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.spell-shape.spark { clip-path: polygon(50% 0,61% 39%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%); }

.spell-body { padding: clamp(0.85rem, 1.2vw, 1.1rem); display: grid; gap: 0.3rem; align-content: start; }
.spell-cat {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
}
.spell-body h3 { font-family: var(--font-display); font-weight: 800; font-size: clamp(1rem, 1.2vw, 1.2rem); line-height: 1.08; }
.spell-body p { font-size: 0.92rem; line-height: 1.45; color: rgba(10,10,10,0.7); }

.spell-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: clamp(0.8rem, 1.4vw, 1.1rem);
  border-top: 2px solid var(--ink);
}
.spell-meta { font-size: 0.74rem; font-weight: 700; color: rgba(10,10,10,0.6); }
.steal-btn {
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-weight: 800; font-size: 0.82rem;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 160ms var(--ease);
}
.steal-btn:hover { background: var(--ink); color: var(--paper); transform: translateY(-1px); }
.steal-btn:focus-visible { outline: 3px solid var(--sapphire); outline-offset: 3px; }

.gallery-empty, .gallery-loading {
  column-span: all; padding: 3rem 0; text-align: center;
  font-weight: 600; color: rgba(10,10,10,0.55);
}

/* featured (home) reveal stagger */
.spell-card-wrap.reveal { opacity: 0; transform: translateY(30px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); transition-delay: calc(var(--i, 0) * 80ms); }
.spell-card-wrap.reveal.is-visible { opacity: 1; transform: none; }

.view-all-wrap { display: flex; justify-content: center; margin-top: clamp(2rem, 4vw, 3.5rem); }

/* ============================================================
   GALLERY TOOLBAR (full page)
   ============================================================ */
.gallery-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: clamp(1.4rem, 3vw, 2.2rem);
}
@media (max-width: 720px) { .gallery-toolbar { grid-template-columns: 1fr; } }
.search {
  display: flex; align-items: center; gap: 0.6rem;
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.7rem 1.1rem; background: var(--paper-pure);
}
.search-ic { width: 20px; height: 20px; color: var(--ink); flex: none; }
.search input { border: 0; background: transparent; font: inherit; font-weight: 600; width: 100%; outline: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.sort-select {
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.7rem 1.1rem; font: inherit; font-weight: 700; background: var(--paper-pure); cursor: pointer;
}

/* custom select (sort) */
.mp-select { position: relative; }
.mp-select-btn {
  display: inline-flex; align-items: center; gap: 0.7rem;
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.7rem 1.15rem; font: inherit; font-weight: 800;
  background: var(--paper-pure); cursor: pointer; white-space: nowrap;
}
.mp-select-chev { width: 18px; height: 18px; color: var(--ink); flex: none; transition: transform 220ms var(--ease); }
.mp-select.is-open .mp-select-chev { transform: rotate(180deg); }
.mp-select-list {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  min-width: 100%; list-style: none; margin: 0; padding: 6px;
  border: 2px solid var(--ink); border-radius: 14px; background: var(--paper-pure);
  box-shadow: -4px 6px 0 var(--ink);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 180ms;
}
.mp-select.is-open .mp-select-list { opacity: 1; visibility: visible; transform: none; }
.mp-select-list li {
  padding: 0.6rem 0.85rem; border-radius: 9px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.mp-select-list li:hover { background: rgba(10,10,10,0.06); }
.mp-select-list li[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.mp-select-btn:focus-visible { outline: 3px solid var(--sapphire); outline-offset: 3px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: clamp(1.4rem, 3vw, 2.2rem); }
.cat-chip {
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.45rem 0.95rem; font-weight: 700; font-size: 0.9rem;
  background: var(--paper-pure); cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.cat-chip:hover { background: rgba(10,10,10,0.06); }
.cat-chip.is-active { background: var(--ink); color: var(--paper); }
.cat-chip:focus-visible, .sort-select:focus-visible, .search:focus-within { outline: 3px solid var(--sapphire); outline-offset: 3px; }

/* ============================================================
   AUTH (login / register)
   ============================================================ */
.auth-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: clamp(6rem, 10vw, 8rem) var(--gutter) 3rem;
}
.auth-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  border: 2px solid var(--ink);
  border-radius: 20px;
  background: var(--paper-pure);
  padding: clamp(1.6rem, 4vw, 2.6rem);
  box-shadow: -8px 8px 0 var(--ink);
}
.auth-card h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.2rem, 5vw, 3rem); letter-spacing: -0.035em; line-height: 0.95;
  margin-bottom: 1.4rem;
}
.auth-sub {
  margin: -0.9rem 0 1.4rem;
  font-size: 0.95rem; font-weight: 600;
  color: rgba(10, 10, 10, 0.6);
}
.field { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.field label { font-weight: 700; font-size: 0.85rem; }
.field input {
  border: 2px solid var(--ink); border-radius: 10px;
  padding: 0.8rem 0.9rem; font: inherit; font-weight: 600; background: var(--paper);
}
.field input:focus-visible { outline: 3px solid var(--sapphire); outline-offset: 2px; }
.auth-card .btn { width: 100%; margin-top: 0.4rem; }
.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; min-height: 52px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper-pure); color: var(--ink);
  font-weight: 800; font-size: 1rem; cursor: pointer; text-decoration: none;
  transition: background 200ms var(--ease), transform 160ms var(--ease);
}
.btn-google:hover { background: rgba(10, 10, 10, 0.05); transform: translateY(-2px); }
.btn-google:focus-visible { outline: 3px solid var(--sapphire); outline-offset: 3px; }
.btn-google svg { width: 20px; height: 20px; flex: none; }
.auth-or {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 1.1rem 0; color: rgba(10, 10, 10, 0.5);
  font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 2px; background: var(--line-soft); }
.auth-alt { margin-top: 1.2rem; font-size: 0.92rem; font-weight: 600; }
.auth-alt a { color: var(--sapphire); font-weight: 800; }
.auth-msg {
  margin-top: 1rem; padding: 0.8rem 1rem; border-radius: 10px;
  font-size: 0.9rem; font-weight: 700; display: none;
}
.auth-msg.is-on { display: block; }
.auth-msg.err { background: color-mix(in srgb, var(--flame) 18%, var(--paper)); border: 2px solid var(--flame); }
.auth-msg.ok { background: color-mix(in srgb, var(--sky) 22%, var(--paper)); border: 2px solid var(--sapphire); }

/* ============================================================
   ACCOUNT
   ============================================================ */
.account-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2vw, 1.6rem); margin-bottom: 2.4rem; }
@media (max-width: 720px) { .account-grid { grid-template-columns: 1fr; } }
.stat-card {
  border: 2px solid var(--ink); border-radius: 16px; padding: clamp(1.2rem, 2vw, 1.8rem);
  background: var(--paper-pure); display: grid; gap: 0.3rem;
}
.stat-card .stat-num { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.4rem, 5vw, 3.6rem); line-height: 0.85; }
.stat-card .stat-label { font-weight: 700; font-size: 0.85rem; color: rgba(10,10,10,0.6); }
.plan-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border-radius: 999px; padding: 0.35rem 0.9rem; font-weight: 800; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.plan-badge.free { background: rgba(10,10,10,0.08); }
.plan-badge.pro { background: var(--gold); }
.account-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.account-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 24px);
  z-index: 200;
  background: var(--ink); color: var(--paper);
  font-weight: 800; font-size: 0.95rem;
  padding: 0.85rem 1.3rem; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .spell-card.reveal { opacity: 1; transform: none; }
  .spell-card.is-visible .spell-bar { animation: none; }
}
