/* ═══════════════════════════════════════════════════════════════
   ÁLBUM DE MEMÓRIAS · screens.css
   Portal · Jardim de boas-vindas · Galeria · Ateliê / Editor
   ═══════════════════════════════════════════════════════════════ */

/* ═══════ TELA 1 · PORTAL (O SELO DE CERA) ═══════ */
#screen-portal {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 50% 0%, #fff 0%, var(--cream) 45%, #F4F0E7 100%);
}
.particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.particles i {
  position: absolute; bottom: -12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f0e0a8, rgba(212,175,55,.25));
  box-shadow: 0 0 10px rgba(212,175,55,.55);
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0%   { transform: translate3d(0, 0, 0) scale(.6); opacity: 0; }
  12%  { opacity: .85; }
  50%  { transform: translate3d(22px, -52vh, 0) scale(1); }
  88%  { opacity: .5; }
  100% { transform: translate3d(-14px, -104vh, 0) scale(.5); opacity: 0; }
}

.portal-card {
  position: relative; z-index: 2;
  width: min(430px, calc(100% - 40px));
  padding: 46px 34px 34px; text-align: center;
  border-radius: var(--r-xl);
  animation: cardIn .9s var(--ease-out);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(.97); } }

.seal {
  width: 84px; height: 84px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 50%;
  color: var(--gold);
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.9), rgba(221,167,165,.20));
  border: 1px solid rgba(212,175,55,.4);
  box-shadow: 0 8px 26px rgba(212,175,55,.16);
  animation: sealPulse 5s ease-in-out infinite;
}
@keyframes sealPulse { 50% { box-shadow: 0 10px 34px rgba(212,175,55,.30); transform: scale(1.03); } }

.portal-instr {
  font-family: var(--garamond); font-style: italic;
  font-size: 1.02rem; color: var(--ink-60); margin-bottom: 26px;
}
#portal-form { position: relative; }
.code-input {
  width: 100%; background: transparent; border: 0; outline: none;
  text-align: center; font-size: 1.35rem; letter-spacing: .45em;
  font-family: var(--ui); font-weight: 300; color: var(--ink);
  padding: 8px 0 12px;
}
.code-input::placeholder { color: rgba(44,44,44,.22); letter-spacing: .45em; }
.code-underline {
  height: 1px; width: 70%; margin: 0 auto;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,.85), transparent);
  position: relative; transition: .4s var(--ease);
}
.code-input:focus ~ .code-underline { width: 88%; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.portal-error {
  min-height: 20px; margin-top: 12px;
  font-size: .74rem; letter-spacing: .1em; color: var(--rose-deep);
  font-style: italic; font-family: var(--garamond); font-size: .95rem;
  opacity: 0; transition: opacity .3s;
}
.portal-error.show { opacity: 1; }
#portal-form.shake { animation: shake .5s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
#portal-form .btn { margin-top: 6px; }
.portal-foot { margin-top: 22px; font-size: .6rem; letter-spacing: .3em; text-transform: lowercase; color: rgba(44,44,44,.28); }

/* ═══════ TELA 2 · JARDIM DE BOAS-VINDAS ═══════ */
#screen-welcome {
  display: grid; place-items: center;
  background:
    radial-gradient(90% 70% at 12% 8%,  rgba(221,167,165,.20), transparent 60%),
    radial-gradient(80% 60% at 88% 12%, rgba(212,175,55,.16),  transparent 62%),
    radial-gradient(100% 80% at 50% 100%, rgba(194,197,170,.22), transparent 65%),
    linear-gradient(180deg, #FDFDFB, #F8F4EC);
}
.petals { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.petals i {
  position: absolute; top: -40px;
  width: 13px; height: 13px;
  background: radial-gradient(circle at 30% 30%, #f6dcda, rgba(221,167,165,.55));
  border-radius: 62% 38% 55% 45% / 55% 48% 52% 45%;
  opacity: .8;
  animation: petalFall linear infinite;
}
@keyframes petalFall {
  0%   { transform: translate3d(0, -8vh, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: .9; }
  50%  { transform: translate3d(60px, 52vh, 0) rotate(220deg); }
  100% { transform: translate3d(-30px, 112vh, 0) rotate(520deg); opacity: 0; }
}
.welcome-inner { position: relative; z-index: 2; text-align: center; padding: 30px 22px; width: 100%; }
.welcome-kicker { font-size: .66rem; letter-spacing: .42em; text-transform: uppercase; color: var(--ink-40); }
.welcome-title { font-family: var(--script); font-size: clamp(2.6rem, 8vw, 4.2rem); line-height: 1.1; margin-top: 8px; }
.welcome-sub { font-family: var(--garamond); font-style: italic; color: var(--ink-60); font-size: 1.05rem; }
.welcome-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.welcome-meta { margin-top: 34px; display: flex; gap: 12px; justify-content: center; align-items: center; }
.welcome-meta .dot { color: var(--ink-12); }

/* ═══════ TELA 3 · GALERIA ═══════ */
#screen-gallery { background: var(--cream); padding-top: var(--topbar-h); }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 0 4vw;
  background: rgba(251,251,249,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(212,175,55,.22);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title .script-title.sm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: .56rem; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-40); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.gallery-root { padding: 34px 0 70px; min-height: 100%; }

@media (max-width: 640px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .rail-head { padding: 0 16px 12px; }
  .rail-track { padding: 10px 16px 22px; gap: 14px; }
  .rail-nav { display: none; }
  .sync-pill { display: none; }
}

/* ═══════ TELA 4 · ATELIÊ ═══════ */
#screen-atelier {
  background: linear-gradient(180deg, #FDFDFB, #F7F4ED);
  padding-top: var(--topbar-h);
}
#screen-atelier .topbar { position: sticky; top: 0; height: auto; padding: 12px 4vw; }
#screen-atelier { padding-top: 0; }

/* ─── Editor de cartas ──────────────────────────────────────── */
.editor-shell { display: grid; grid-template-columns: 268px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .editor-shell { grid-template-columns: 1fr; } }

.editor-tools {
  position: sticky; top: calc(var(--topbar-h) + 14px);
  max-height: calc(100vh - var(--topbar-h) - 40px);
  overflow-y: auto; padding-right: 4px;
}
@media (max-width: 900px) {
  .editor-tools { position: static; max-height: none; order: 2; }
  .editor-stage { order: 1; }
}
.tool-group { margin-bottom: 14px; }
.tool-group > h4 {
  font-size: .6rem; letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink-40); margin-bottom: 9px; font-family: var(--ui); font-weight: 400;
}
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 11px 6px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--ink-12); background: rgba(255,255,255,.68);
  font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-60);
  transition: .3s var(--ease);
}
.tool-btn:hover { border-color: rgba(212,175,55,.65); color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.tool-btn svg { color: var(--rose); }
.tool-btn.wide { grid-column: 1 / -1; flex-direction: row; }

.editor-stage {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 8px 0 20px;
}
.canvas-hold {
  position: relative;
  filter: drop-shadow(0 22px 46px rgba(44,44,44,.13));
}
.letter-canvas {
  position: relative; overflow: hidden;
  transform-origin: top left;
  background: #fff;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.letter-canvas * { box-sizing: border-box; }

.lc-el { position: absolute; transform-origin: center center; }
.lc-el.is-selected { outline: 1px dashed rgba(212,175,55,.9); outline-offset: 3px; }
.lc-el[data-type="text"] {
  cursor: move; white-space: pre-wrap; word-break: break-word; line-height: 1.3;
}
.lc-el[data-type="text"][contenteditable="true"] {
  outline: 1px solid rgba(212,175,55,.7) !important; cursor: text;
  background: rgba(255,255,255,.35);
}
.lc-el svg { display: block; width: 100%; height: 100%; overflow: visible; }
.lc-el img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Handles de redimensionamento / rotação */
.lc-handles { position: absolute; inset: -3px; pointer-events: none; }
.lc-handles i {
  position: absolute; width: 13px; height: 13px; border-radius: 3px;
  background: #fff; border: 1.5px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,.14);
  pointer-events: auto; touch-action: none;
}
.lc-handles i[data-h="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.lc-handles i[data-h="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.lc-handles i[data-h="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.lc-handles i[data-h="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }
.lc-handles .rot {
  width: 22px; height: 22px; border-radius: 50%; left: 50%; top: -34px;
  transform: translateX(-50%); display: grid; place-items: center; cursor: grab;
}
.lc-handles .rot::after {
  content: ''; position: absolute; top: 21px; left: 50%; width: 1px; height: 12px;
  background: var(--gold);
}
.lc-handles .rot svg { color: var(--gold); width: 12px; height: 12px; }

.editor-inspector {
  width: min(560px, 100%);
  border-radius: var(--r-md); padding: 14px 16px;
  background: rgba(255,255,255,.72); border: 1px solid rgba(212,175,55,.24);
  box-shadow: var(--shadow-soft);
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
}
.insp { display: flex; align-items: center; gap: 7px; }
.insp > label { font-size: .56rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-40); }
.insp .input, .insp .select { padding: 7px 10px; font-size: .76rem; width: auto; }
.insp input[type="number"] { width: 74px; }
.insp input[type="range"] { width: 96px; accent-color: var(--gold); }
.insp input[type="color"] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--ink-12); border-radius: 6px; background: #fff; cursor: pointer; }

.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 6px; }

/* Selo "Nova carta / Editando: X" na barra de ações do editor */
.editor-banner {
  padding: 7px 14px; border-radius: 999px;
  font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-40); border: 1px dashed var(--ink-12);
  background: rgba(255, 255, 255, .55);
  max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.editor-banner.is-edit {
  color: #8a7327; border: 1px solid rgba(212, 175, 55, .6);
  background: rgba(212, 175, 55, .12);
}

/* ─── Quadro Grupos & Cartas ────────────────────────────────── */
.board-group { margin-bottom: 26px; }
.board-group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(212, 175, 55, .24);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.board-group-head h3 { font-family: var(--garamond); font-size: 1.15rem; font-weight: 500; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, .45);
  border: 1px solid rgba(212, 175, 55, .18);
  border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md);
}

.board-card {
  display: flex; flex-direction: column; gap: 9px;
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(212, 175, 55, .2);
  border-radius: var(--r-md);
  padding: 10px;
  box-shadow: var(--shadow-card);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.board-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

.board-thumb {
  height: 130px; border-radius: var(--r-sm);
  background: var(--cream-2) center/cover no-repeat;
  border: 1px solid var(--ink-12);
  display: grid; place-items: center; color: var(--rose);
}
.board-card-info b { display: block; font-family: var(--garamond); font-weight: 500; font-size: 1rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-card-info span { font-size: .56rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-40); }

.board-card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.board-card-actions .icon-btn { width: 30px; height: 30px; flex: 0 0 30px; }
.board-move {
  flex: 1; min-width: 96px; padding: 6px 8px; font-size: .68rem;
  border-radius: var(--r-sm);
}

@media (max-width: 640px) {
  .board-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 10px; }
}

/* ─── Uploads ───────────────────────────────────────────────── */
.upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.cover-choice { display: flex; gap: 10px; align-items: flex-start; }
.cover-preview {
  width: 78px; height: 112px; border-radius: 8px; object-fit: cover; flex: 0 0 78px;
  border: 1px solid var(--ink-12); background: var(--cream-2);
}
.file-chip {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--r-sm); background: rgba(255,255,255,.7);
  border: 1px solid rgba(212,175,55,.24); margin-top: 10px;
}
.file-chip .name { flex: 1; min-width: 0; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .size { font-size: .6rem; letter-spacing: .14em; color: var(--ink-40); text-transform: uppercase; }

/* ─── Gestão ────────────────────────────────────────────────── */
.manage-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.publish-bar {
  position: sticky; bottom: 14px; z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 999px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(212,175,55,.4);
  box-shadow: 0 18px 44px rgba(44,44,44,.10);
  margin-top: 22px;
}
.publish-bar .info { flex: 1; min-width: 180px; font-size: .72rem; color: var(--ink-60); line-height: 1.5; }

/* ─── Conexão GitHub (modal) ────────────────────────────────── */
.gh-status {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: var(--r-sm); font-size: .76rem; margin-bottom: 16px;
  border: 1px solid var(--ink-12); background: rgba(255,255,255,.6);
}
.gh-status .led { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-12); flex: 0 0 9px; }
.gh-status.ok .led { background: var(--sage); box-shadow: 0 0 10px rgba(194,197,170,.9); }
.gh-status.err .led { background: var(--rose-deep); }
.gh-status.busy .led { background: var(--gold); animation: pulse 1.2s infinite; }
