/* Base styles — reset, body, layout, buttons, flash, nav */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--theme-bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 9998;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 125%; }
@media (max-width: 768px) { html { font-size: 100%; } }
body { font-family: var(--theme-font); background: var(--theme-bg); color: var(--theme-text); min-height: 100vh; }
a { color: var(--theme-accent); }

.container { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 1rem; }
@media (min-width: 1400px) { .container { max-width: 1200px; } }
@media (max-width: 768px) {
  .container { padding: 0.5rem 0.6rem; }
  .app-nav-tokens-count { display: block; }
}

.btn { display: inline-block; padding: 0.5rem 1.2rem; border: 1px solid var(--theme-accent); background: transparent; color: var(--theme-accent); cursor: pointer; font-family: inherit; font-size: 0.9rem; text-decoration: none; }
.btn:hover { background: var(--theme-accent); color: var(--theme-bg); }
.btn-primary { background: var(--theme-accent); color: var(--theme-bg); }
.btn-primary:hover { background: #6a9480; }
.btn-danger { border-color: #6a3030; color: #8a4040; font-size: 0.72rem; padding: 0.35rem 0.8rem; }
.btn-danger:hover { background: #6a3030; color: #e0d4bc; }

.flash-notice { background: #1a3a2a; border: 1px solid var(--theme-accent); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.flash-alert { background: #3a1a1a; border: 1px solid #a08080; color: #c8a0a0; padding: 0.75rem 1rem; margin-bottom: 1rem; }

h1, h2, h3 { color: #e8e8d4; font-weight: normal; letter-spacing: 0.05em; }

.app-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.5rem 0.75rem; padding: 0.4rem 0 0.75rem; border-bottom: 1px solid #1e1810; margin-bottom: 0.75rem; font-size: 0.7rem; }
.app-nav-home { text-decoration: none; margin-right: auto; display: flex; align-items: center; }
.app-nav-home:hover { opacity: 0.8; }
.app-nav-icon { height: 1.6rem; width: auto; }
.app-nav-user { font-family: 'Lora', Georgia, serif; font-style: italic; color: #4a4030; max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav-tokens { color: #4a4030; font-size: 0.65rem; letter-spacing: 0.05em; max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav-signout { background: transparent; border: 1px solid #2a2318; color: #4a4030; padding: 0.2rem 0.4rem; cursor: pointer; font-family: 'Cinzel', serif; font-size: 0.6rem; letter-spacing: 0.1em; line-height: 1.2; }
.app-nav-signout:hover { color: var(--theme-accent); border-color: #3a3020; }
.app-nav-locale { background: transparent; border: 1px solid #2a2318; color: #4a4030; padding: 0.2rem 0.4rem; cursor: pointer; font-family: 'Cinzel', serif; font-size: 0.6rem; letter-spacing: 0.1em; line-height: 1.2; appearance: none; -webkit-appearance: none; }
.app-nav-locale:hover { color: var(--theme-accent); border-color: #3a3020; }

.token-banner { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 9999; background: #2a1010; border: 1px solid #6a3030; padding: 0.75rem 2.5rem 0.75rem 1.25rem; font-family: 'Lora', Georgia, serif; font-size: 0.82rem; color: #c8a0a0; box-shadow: 0 4px 20px rgba(0,0,0,0.6); max-width: 480px; width: calc(100% - 2rem); }
.token-banner-text { display: block; }
.token-banner-close { position: absolute; top: 0.4rem; right: 0.6rem; background: none; border: none; color: #6a4040; font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 0.2rem; }
.token-banner-close:hover { color: #c8a0a0; }

/* ── Loading overlay ── */
.loading-overlay[hidden] { display: none !important; }
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-conic-gradient(rgba(120, 90, 50, 0.03) 0% 25%, transparent 0% 50%) 0 0 / 4px 4px,
    radial-gradient(ellipse at 0% 0%, rgba(90, 60, 30, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(90, 55, 25, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 40%, #efe3cd 0%, #e2d3b8 40%, #d4c4a4 80%);
  animation: overlayFadeIn 0.3s ease-out both;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.loading-overlay-content { text-align: center; }
.loading-overlay-title {
  font-family: 'Cinzel', 'Palatino Linotype', serif;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #3a2a14;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.5);
  margin-bottom: 1.5rem;
}
.loading-overlay-dots {
  display: flex;
  gap: 0.45rem;
  justify-content: center;
}
.loading-overlay-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8a7354;
  animation: loadPulse 1.4s ease-in-out infinite;
}
.loading-overlay-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-overlay-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loadPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Site footer — legal links ── */
.site-footer {
  text-align: center;
  padding: 2rem 1rem 1.2rem;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  position: relative;
  z-index: 1;
}

.site-footer a {
  color: #4a4030;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}
.site-footer a:hover { opacity: 1; }

.site-footer-dot {
  display: inline-block;
  margin: 0 0.6em;
  color: #4a4030;
  opacity: 0.5;
  opacity: 0.25;
  font-style: normal;
}

/* Parchment pages (sign-in, legal) — warm tones */
body:has(.signin-screen) .site-footer a,
body:has(.legal-page) .site-footer a { color: #9a8568; }
body:has(.signin-screen) .site-footer-dot,
body:has(.legal-page) .site-footer-dot { color: #9a8568; }
