/* ===== FONTS ===== */
@font-face {
  font-family: 'EditorialNew';
  src: url('assets/fonts/EditorialNew-Regular copy.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TomatoGrotesk';
  src: url('assets/fonts/TomatoGroteskTrial-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #FFFFFF;
  --bg-warm: #C4A96A;
  --bg-cream: #F5F0E8;
  --bg-dark: #1A1A1A;
  --text: #1A1A1A;
  --text-warm: #3A2E1F;
  --text-muted: #8A8278;
  --accent: #C75B3F;
  --accent-soft: #F2DDD6;
  --green: #4A7C59;
  --green-light: #A8D5A2;
  --card-bg: #F5F0E8;
  --border: #E8E0D6;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font-heading: 'EditorialNew', Georgia, serif;
  --font-body: 'TomatoGrotesk', 'Inter', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.15;
}

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

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== APP & PAGE SYSTEM ===== */
#app {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.page {
  display: none;
  flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.page.active {
  display: flex;
  opacity: 1;
  transform: translateX(0);
}

.page.exit {
  opacity: 0;
  transform: translateX(-30px);
}

.page-dark {
  background: var(--bg-dark);
}

.page-warm {
  background: var(--bg-warm);
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.page-header h2 {
  font-size: 1.1rem;
  font-weight: 400;
  font-family: var(--font-body);
}

.page-header-transparent {
  background: transparent;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.page-header-warm {
  background: var(--bg-warm);
}

.page-dark .page-header {
  background: var(--bg-dark);
}

.btn-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.25);
  color: var(--text);
  transition: transform 0.2s;
}

.btn-back:active {
  transform: scale(0.92);
}

.btn-back-light {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn-back-warm {
  background: rgba(255,255,255,0.25);
  color: var(--text-warm);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px;
  border-radius: 60px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-body);
  transition: transform 0.2s, box-shadow 0.2s;
  letter-spacing: 0.01em;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: #ed5f36;
  color: #fff;
  box-shadow: 0 4px 16px rgba(237,95,54,0.25);
}

.btn-secondary {
  background: #cbe070;
  color: #000;
  border: none;
}

.btn-full {
  width: 100%;
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 60px;
  background: #5d98f9;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-body);
  transition: transform 0.2s;
  border: none;
  cursor: pointer;
}

.btn-scan:active {
  transform: scale(0.96);
}

.btn-scan-text {
  font-family: var(--font-body);
}

/* ===== HOME PAGE ===== */
#page-home {
  background: var(--bg-cream);
}

.home-top {
  padding: 48px 24px 20px;
}

.home-logo-block {
  display: inline-block;
}

.logo-image {
  width: 220px;
  height: auto;
  display: block;
}

/* Hero image / glass animation */
.home-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.1;
  overflow: visible;
  border-radius: 0 0 32px 32px;
}

.home-hero.clipped {
  overflow: hidden;
}

.hero-layers {
  position: absolute;
  inset: 0;
}

/* === Glass panel base === */
.hero-layer-wrap {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  opacity: 0;
  transform-origin: 50% 95%;
  /* full animation shorthand is set per-layer via inline style */
}

.hero-layer-wrap .hero-layer {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  backface-visibility: hidden;
}

/* Glass reflection */
.hero-layer-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(
    125deg,
    rgba(255,255,255,0.4) 0%,
    rgba(255,255,255,0.1) 20%,
    transparent 45%,
    rgba(255,255,255,0.04) 80%,
    rgba(255,255,255,0.15) 100%
  );
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.6s ease;
}

.home-hero.clipped .hero-layer-wrap::after {
  opacity: 0;
}

/* Glass block edge */
.hero-layer-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.4);
  box-shadow:
    inset 2px 2px 6px rgba(255,255,255,0.3),
    inset -1px -1px 4px rgba(0,0,0,0.08),
    6px 12px 48px rgba(0,0,0,0.45),
    2px 4px 12px rgba(0,0,0,0.30);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.6s ease;
}

.home-hero.clipped .hero-layer-wrap::before {
  opacity: 0;
}

/* Shadow fades out as each layer transitions in */
.hero-layer-wrap.settling::before,
.hero-layer-wrap.settling::after {
  opacity: 0;
  transition: opacity 1400ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* === Layer stacking (1 = back, 7 = front) === */
.layer-1 { z-index: 1; }
.layer-2 { z-index: 2; }
.layer-3 { z-index: 3; }
.layer-4 { z-index: 4; }
.layer-5 { z-index: 5; }
.layer-6 { z-index: 6; }
.layer-7 { z-index: 7; }


.hero-layers.assembled .hero-layer-wrap {
  animation: glassIdle 6s ease-in-out infinite;
  opacity: 1;
}

.hero-layers.assembled .hero-layer-wrap:nth-child(odd) {
  animation-direction: reverse;
}

@keyframes glassIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Parallax */
.hero-layers.interactive .hero-layer-wrap {
  animation: none !important;
  opacity: 1;
  transition: transform 0.25s ease-out;
}

/* Home body */
.home-body {
  padding: 28px 24px calc(36px + var(--safe-bottom));
}

.home-description {
  font-family: var(--font-body);
  font-size: 1.9rem;
  line-height: 1.08;
  color: #000;
  margin-bottom: 28px;
}

.home-actions {
  display: flex;
  gap: 12px;
}

/* ===== ROUTES PAGE ===== */
.routes-content {
  flex: 1;
  padding: 0 20px calc(28px + var(--safe-bottom));
}

.routes-title {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  color: var(--text-warm);
  margin-bottom: 28px;
  line-height: 1.1;
}

.routes-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.route-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  background: var(--bg-cream);
  border-radius: var(--radius);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  animation: fadeInUp 0.4s ease backwards;
}

.route-card:active {
  transform: scale(0.98);
}

.route-card:nth-child(1) { animation-delay: 0.05s; }
.route-card:nth-child(2) { animation-delay: 0.12s; }
.route-card:nth-child(3) { animation-delay: 0.19s; }

.route-card-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.route-emoji {
  font-size: 2rem;
}

.route-card-body {
  flex: 1;
  min-width: 0;
}

.route-card-body h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-warm);
  margin-bottom: 2px;
}

.route-card-body p {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.route-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ===== MAP PAGE ===== */
.map-container {
  flex: 1;
  padding: 0 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
}

#museum-map {
  width: 100%;
  max-height: calc(100dvh - 160px);
}

.map-room-label {
  font-family: var(--font-body);
  font-size: 12px;
  fill: var(--text-muted);
  font-weight: 500;
}

.map-marker {
  cursor: pointer;
  pointer-events: all;
}

.map-marker circle.marker-bg {
  fill: var(--accent);
  transition: r 0.15s ease, fill 0.2s;
  pointer-events: all;
  cursor: pointer;
}

.map-marker:hover circle.marker-bg,
.map-marker:active circle.marker-bg {
  r: 16;
}

.map-marker text {
  font-family: var(--font-body);
  font-size: 10px;
  fill: #fff;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.map-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px calc(16px + var(--safe-bottom));
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

#tour-path {
  stroke: var(--accent);
  opacity: 0.5;
}

/* ===== ARTWORK PAGE ===== */
.artwork-hero {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--border);
}

.artwork-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.artwork-info {
  padding: 24px 20px calc(24px + var(--safe-bottom));
}

.artwork-info h2 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--text-warm);
  margin-bottom: 14px;
  line-height: 1.15;
}

/* Artwork tag pills */
.artwork-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tag {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 40px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tag-red {
  background: #ed5f36;
  color: #fff;
}

.tag-green {
  background: #cbe070;
  color: #000;
}

.tag-dark {
  background: #5d98f9;
  color: #fff;
}

.artwork-description {
  font-size: 0.9rem;
  line-height: 1.65;
  color: #555;
  margin-bottom: 28px;
}

.artwork-description p {
  font-family: var(--font-body);
}

/* ===== QR SCANNER PAGE ===== */
.scanner-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 28px;
}

.scanner-viewfinder {
  width: 260px;
  height: 260px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewfinder-frame {
  position: absolute;
  inset: 0;
}

.vf-corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: #fff;
  border-style: solid;
  border-width: 0;
}

.vf-tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 8px 0 0 0; }
.vf-tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 8px 0 0; }
.vf-bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 8px; }
.vf-br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 8px 0; }

.scanner-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 0; }
}

.scanner-line {
  position: absolute;
  left: 20px;
  right: 20px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanLine 2.5s ease-in-out infinite;
}

@keyframes scanLine {
  0% { top: 30px; }
  50% { top: calc(100% - 30px); }
  100% { top: 30px; }
}

.scanner-hint {
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  text-align: center;
  max-width: 240px;
  line-height: 1.4;
  font-family: var(--font-body);
}

.scanner-demo-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.scanner-demo-label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.scanner-demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scanner-demo-btn {
  padding: 10px 20px;
  border-radius: 40px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-body);
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  transition: background 0.2s, transform 0.2s;
}

.scanner-demo-btn:active {
  transform: scale(0.95);
  background: rgba(255,255,255,0.2);
}

/* ===== REVEAL PAGE ===== */
.reveal-container {
  flex: 1;
  overflow-y: auto;
}

.reveal-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.75;
  overflow: hidden;
  background: var(--border);
}

.reveal-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reveal-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.4) 50%,
    transparent 60%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out 1;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.reveal-content {
  padding: 24px 20px calc(24px + var(--safe-bottom));
}

.reveal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.25);
  color: var(--text-warm);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: 40px;
  margin-bottom: 16px;
}

.reveal-content h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--text-warm);
  margin-bottom: 4px;
}

.reveal-artist {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-family: var(--font-body);
}

.reveal-story {
  margin-bottom: 20px;
}

.reveal-story h3 {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-warm);
}

.reveal-story p {
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.6;
  color: #555;
}

.reveal-fun-fact {
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 28px;
}

.fun-fact-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 6px;
  font-family: var(--font-body);
}

.reveal-fun-fact p {
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.5;
  color: #555;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 0;
}

/* ===== DESKTOP PREVIEW WRAPPER ===== */
@media (min-width: 431px) {
  body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background: #F0F0F0;
  }
  #app {
    margin-top: 20px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
    background: var(--bg);
    min-height: calc(100vh - 40px);
  }
}
