/* ═══════════════════════════════════════════════════════════════
   base.css — layout, page surface, lightweight animations
═══════════════════════════════════════════════════════════════ */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html{scroll-behavior:smooth;}

body {
  background-color: var(--bg-color);
  color: var(--text);
  font-family: var(--font-base, var(--font-ar));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  transition: background-color .3s ease, color .3s ease;
}
/* Fixed, GPU-composited background layer (cheaper than background-attachment:fixed) */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background-color: var(--bg-color);
  background-image: var(--bg-image);
  background-size: cover, 520px auto;
  background-position: center, center;
  pointer-events: none;
}
[data-theme="light"] body::before { background-size: auto, 48px 48px; }

/* ── Loading (shows the logo instantly) ─────────────────────── */
#loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100dvh; gap: 1rem;
  color: var(--accent);
}
.loading-logo { width: 140px; height: 140px; object-fit: contain; filter: var(--logo-glow); }
.loader-ring {
  width: 30px; height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App container ───────────────────────────────────────────── */
#app { display:flex; justify-content:center; padding: 2rem 1rem 5rem; }
@media(max-width:520px){ #app{padding:0 0 5rem;} }

#content { opacity: 0; transition: opacity .35s var(--ease-ink); }
#content.content-visible { opacity:1; }

/* ── Paper Sheet ─────────────────────────────────────────────── */
.paper-sheet {
  position: relative;
  width: 100%; max-width: 780px;
  background: var(--sheet-bg);
  border-radius: 6px;
  padding: 3rem 2.25rem;
  box-shadow: 0 0 0 1px var(--sheet-line), 0 24px 60px rgba(0,0,0,.45);
}
.paper-sheet::after {
  content:""; position:absolute; inset:10px; pointer-events:none; z-index:0;
  border:1px solid var(--sheet-line); border-radius: 4px;
}
.paper-sheet > * { position:relative; z-index:1; }

/* Light: aged paper vignette + double Russian frame (red + gold) */
[data-theme="light"] .paper-sheet {
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(140,90,35,.22) 100%),
    var(--sheet-bg);
  box-shadow: 0 0 0 1px rgba(142,27,18,.35), 0 18px 45px rgba(90,55,20,.30);
}
[data-theme="light"] .paper-sheet::after {
  inset: 9px;
  border: 2px solid rgba(142,27,18,.55);
  outline: 1px solid rgba(168,124,36,.55);
  outline-offset: 4px;
}

@media(max-width:520px){
  .paper-sheet{ padding:2rem 1rem; border-radius:0; }
  .paper-sheet::after { inset:6px; }
}

/* ── Typography ──────────────────────────────────────────────── */
h1,h2,h3,h4,h5{ font-family:var(--font-title); font-weight:700; line-height:1.2; }
a{ color:inherit; text-underline-offset:3px; text-decoration-thickness:1px; }

/* ══════════════════════════════════════════════════════════════
   LIGHTWEIGHT ANIMATIONS (transform/opacity only)
══════════════════════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:none; }
}
.stamp-in { animation: fadeUp .4s var(--ease-ink) both; }
.category { animation: fadeUp .45s var(--ease-ink) both; animation-delay: calc(var(--cat-i, 0) * 60ms); }

@keyframes sealIn {
  from { opacity:0; transform:scale(.6); }
  to   { opacity:1; transform:scale(1); }
}
.wax-seal { animation: sealIn .4s var(--ease-ink) .5s both; }

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
