/* ── Reset & custom properties ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg:          #f4f1ec;
  --clr-surface:     #fdfaf5;
  --clr-border:      #ddd6ca;
  --clr-primary:     #1a1248;
  --clr-primary-lt:  #2f2170;
  --clr-accent:      #c9963d;
  --clr-accent-lt:   #e8c574;
  --clr-accent-glow: rgba(201,150,61,.18);
  --clr-text:        #16120d;
  --clr-muted:       #74685e;
  --clr-error:       #a8302a;
  --clr-disclaimer:  #7a4a00;
  --clr-consent:     #1a471a;
  --clr-privacy:     #1a2e50;

  --radius:    12px;
  --radius-sm:  8px;
  --shadow:    0 2px 16px rgba(26,18,72,.07);
  --shadow-lg: 0 8px 40px rgba(26,18,72,.13);
  --shadow-gold: 0 4px 24px rgba(201,150,61,.15);

  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans:    system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif:   'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

/* ── Base ───────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

img { max-width: 100%; display: block; }

/* ── Header ─────────────────────────────────────────────────────────── */
.site-header {
  position: relative;
  background: linear-gradient(160deg, #0c0926 0%, #1a1248 55%, #261b5c 100%);
  color: #fff;
  padding: 1.75rem 1rem 1.5rem;
  text-align: center;
  overflow: hidden;
}

/* Warm ambient glow beneath the title */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 90% at 50% 120%, rgba(201,150,61,.13) 0%, transparent 65%),
    radial-gradient(ellipse 35% 50% at 15% 15%, rgba(255,255,255,.04) 0%, transparent 55%);
  pointer-events: none;
}

.site-header__inner { position: relative; }

.site-eyebrow {
  font-size: .9375rem;
  color: var(--clr-accent);
  letter-spacing: .25em;
  margin-bottom: .4rem;
  opacity: .9;
}

.site-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1;
}

.site-subtitle {
  font-size: .8125rem;
  color: rgba(255,255,255,.55);
  letter-spacing: .14em;
  text-transform: uppercase;
  margin-top: .5rem;
}

/* ── Main & sections ────────────────────────────────────────────────── */
.main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section { display: flex; flex-direction: column; gap: 1rem; }
.section--centered { align-items: center; text-align: center; padding: 3rem 1rem; }

/* ── Section entrance animation ─────────────────────────────────────── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.is-entering {
  animation: fade-in-up .4s cubic-bezier(.22,.68,0,1.1) both;
}

/* ── Notices ────────────────────────────────────────────────────────── */
.notices {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .625rem .875rem;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  line-height: 1.4;
  font-weight: 500;
}

.notice__icon {
  flex-shrink: 0;
  font-style: normal;
  font-size: 1rem;
  line-height: 1;
  margin-top: .0625rem;
}

.notice--disclaimer {
  background: #fff8e6;
  color: var(--clr-disclaimer);
  border: 1px solid #f0d88a;
}

.notice--consent {
  background: #edf7ed;
  color: var(--clr-consent);
  border: 1px solid #a8d5a8;
}

.notice--privacy {
  background: #e8f0fa;
  color: var(--clr-privacy);
  border: 1px solid #a8c4e8;
}

.notices--result { margin-top: .5rem; }

/* ── Drop zone ──────────────────────────────────────────────────────── */
.drop-zone {
  background: var(--clr-surface);
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .25s, background .25s, box-shadow .25s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--clr-primary);
  background: #efebf6;
  outline: none;
  box-shadow: 0 0 0 3px rgba(26,18,72,.1), var(--shadow);
}

.drop-zone.is-over {
  border-color: var(--clr-accent);
  background: #fdf7ed;
  box-shadow: 0 0 0 3px var(--clr-accent-glow), var(--shadow-gold);
}

.drop-zone__icon {
  font-size: 2.25rem;
  line-height: 1;
  color: var(--clr-accent);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .25s;
  opacity: .75;
}

.drop-zone:hover .drop-zone__icon,
.drop-zone:focus-visible .drop-zone__icon,
.drop-zone.is-over .drop-zone__icon {
  transform: scale(1.18) rotate(18deg);
  opacity: 1;
}

.drop-zone__primary {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--clr-primary);
}

.drop-zone__secondary {
  font-size: .875rem;
  color: var(--clr-muted);
  margin-top: -.375rem;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  justify-content: center;
  margin-top: .25rem;
}

.size-hint {
  text-align: center;
  font-size: .75rem;
  color: var(--clr-muted);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
  text-decoration: none;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: 3px solid var(--clr-accent);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--clr-primary);
  color: #fff;
}

.btn--primary:hover { background: var(--clr-primary-lt); box-shadow: var(--shadow); }
.btn--primary:active { background: var(--clr-primary); opacity: .85; }

.btn--secondary {
  background: transparent;
  color: var(--clr-primary);
  border-color: var(--clr-primary);
}

.btn--secondary:hover { background: rgba(26,18,72,.06); }

.btn--outline {
  background: transparent;
  color: var(--clr-muted);
  border-color: var(--clr-border);
  width: 100%;
  padding: .75rem;
  font-size: 1rem;
}

.btn--outline:hover { border-color: var(--clr-primary); color: var(--clr-primary); }

/* ── Oracle loading animation ───────────────────────────────────────── */
.oracle {
  position: relative;
  width: 5rem;
  height: 5rem;
  margin: .5rem auto;
}

.oracle__ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid transparent;
}

.oracle__ring--outer {
  inset: 0;
  border-top-color: var(--clr-accent);
  border-right-color: rgba(201,150,61,.38);
  animation: oracle-cw 2.8s linear infinite;
}

.oracle__ring--mid {
  inset: 10px;
  border-bottom-color: var(--clr-accent);
  border-left-color: rgba(201,150,61,.32);
  animation: oracle-ccw 1.9s linear infinite;
}

.oracle__dot {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--clr-accent-lt) 0%, var(--clr-accent) 55%, transparent 100%);
  animation: oracle-pulse 2s ease-in-out infinite;
}

@keyframes oracle-cw  { to { transform: rotate(360deg); } }
@keyframes oracle-ccw { to { transform: rotate(-360deg); } }
@keyframes oracle-pulse {
  0%, 100% { opacity: .45; transform: scale(.72); }
  50%       { opacity: 1;   transform: scale(1); }
}

.loading-text {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--clr-primary);
  transition: opacity .3s ease;
  min-height: 1.7em;
}

.loading-text.is-fading { opacity: 0; }

.loading-sub { font-size: .875rem; color: var(--clr-muted); }

/* ── Result: arc badge ──────────────────────────────────────────────── */
.arc-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: .3125rem .875rem;
  background: linear-gradient(135deg, var(--clr-primary) 0%, var(--clr-primary-lt) 100%);
  color: #fff;
  border-radius: 100px;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .04em;
  box-shadow: 0 2px 8px rgba(26,18,72,.22);
}

.arc-badge:empty { display: none; }

/* ── Result: narrative card ─────────────────────────────────────────── */
.narrative {
  background: var(--clr-surface);
  border-radius: var(--radius);
  padding: 0 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

/* Gold gradient stripe — first flex child, bleeds to card edges */
.narrative::before {
  content: '';
  display: block;
  flex-shrink: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--clr-primary-lt) 0%,
    var(--clr-accent) 35%,
    var(--clr-accent-lt) 50%,
    var(--clr-accent) 65%,
    var(--clr-primary-lt) 100%
  );
  margin: 0 -1.25rem 1.5rem;
}

/* First paragraph — lead, large serif */
.narrative__lead {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 3.5vw, 1.375rem);
  line-height: 1.55;
  color: var(--clr-text);
  font-weight: 400;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--clr-border);
  margin-bottom: 1rem;
}

/* Middle paragraphs */
.narrative__body {
  font-size: clamp(.9rem, 2.8vw, 1rem);
  line-height: 1.75;
  color: var(--clr-text);
  margin-bottom: .875rem;
}

.narrative__body:last-child { margin-bottom: 0; }

/* Last paragraph — smaller, italic, muted */
.narrative__tail {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(.875rem, 2.5vw, .9375rem);
  line-height: 1.6;
  color: var(--clr-muted);
  border-top: 1px solid var(--clr-border);
  padding-top: .875rem;
  margin-top: .125rem;
}

/* ── Error ──────────────────────────────────────────────────────────── */
.error-icon {
  font-size: 2.5rem;
  color: var(--clr-error);
}

.error-message {
  font-size: 1rem;
  color: var(--clr-error);
  max-width: 30ch;
  text-align: center;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1rem;
  font-size: .75rem;
  color: var(--clr-muted);
  border-top: 1px solid var(--clr-border);
}

/* ── Responsive: wider screens ──────────────────────────────────────── */
@media (min-width: 480px) {
  .main { padding: 2rem 1.5rem 3rem; }
  .drop-zone { padding: 2.5rem 2rem; }

  .narrative {
    padding: 0 1.75rem 2rem;
  }

  .narrative::before {
    margin: 0 -1.75rem 1.75rem;
  }

  #camera-btn { display: none; }
}

@media (max-width: 479px) {
  .drop-zone__buttons { flex-direction: column; width: 100%; }
  .drop-zone__buttons .btn { width: 100%; }
}

/* ── Utility ────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
