/* ============================================================
   Aquarium Pula Audioguide — mobile-first styles
   Designed for phones first; scales up gracefully on tablets.
   ============================================================ */

:root {
  --deep:   #0b3d5c;   /* deep sea blue (header / accents) */
  --teal:   #1390a3;   /* accent */
  --bg:     #f4f7f9;   /* page background */
  --card:   #ffffff;
  --text:   #1d2b33;
  --muted:  #5a6b75;
  --line:   #e1e8ed;
  --radius: 14px;
  --maxw:   640px;     /* keeps it readable on big screens */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--deep);
  color: #fff;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  padding: 8px 4px;
  min-height: 44px;            /* comfortable touch target */
}
.back-arrow { font-size: 20px; line-height: 1; }

/* ---------- Top-bar right-side actions ---------- */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
  border: 0;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.26); }

/* ---------- Language switcher ---------- */
.lang-switch { position: relative; }

.lang-flag {
  font-size: 18px;
  line-height: 1;
}

.lang-option-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.lang-btn:active { background: rgba(255, 255, 255, 0.26); }
.chevron { font-size: 12px; opacity: 0.85; }

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  min-width: 170px;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.lang-option:active { background: var(--bg); }
.lang-option.is-active {
  color: var(--deep);
  font-weight: 700;
}
.lang-option.is-active::after {
  content: "\2713";           /* checkmark */
  color: var(--teal);
  font-weight: 700;
}

/* ---------- Exhibit content ---------- */
.exhibit {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.exhibit-title {
  font-size: 26px;
  line-height: 1.25;
  margin: 8px 0 18px;
  color: var(--deep);
  letter-spacing: 0.2px;
}

/* ---------- Exhibit media (image or sub-page grid) ---------- */
.exhibit-media {
  margin-bottom: 22px;
}

/* Single image */
.exhibit-media.is-single .media-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(11, 61, 92, 0.10);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--deep);
}

/* Grid of sub-page links (parent exhibits) — small thumbnails.
   2 per row on phones, 4 per row on wider screens; the grid is capped
   and centred so the tiles stay small. */
.exhibit-media.is-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 560px) {
  .exhibit-media.is-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 560px;
  }
}

.media-cell {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(11, 61, 92, 0.06);
}
.media-cell:active { background: var(--bg); }
.media-cell .media-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--deep);
}
.media-cap {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;       /* keep captions to 2 lines max */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Audio player ---------- */
.player {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 2px 10px rgba(11, 61, 92, 0.06);
  margin-bottom: 22px;
}
.player audio {
  width: 100%;
  display: block;
}

/* ---------- Text + See more ---------- */
.exhibit-text {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 10px rgba(11, 61, 92, 0.06);
}

#exhibitText {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}
#exhibitText .para {
  display: block;
}
#exhibitText .para + .para {
  margin-top: 14px;
}

.toggle-text {
  display: inline-block;
  margin-top: 14px;
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--teal);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}
.toggle-text:active { opacity: 0.7; }

/* ---------- Homepage / exhibits menu ---------- */
.site-name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   MAP HOMEPAGE  (animated exploded floors)
   ============================================================ */
body.map-page {
  background:
    radial-gradient(120% 80% at 50% 12%, #14688a 0%, #0b3d5c 55%, #062a3f 100%);
  color: #fff;
  min-height: 100vh;
}

/* Make the top bar blend into the map's dark background */
.topbar--map {
  background: transparent;
}

.map {
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map-intro {
  text-align: center;
  margin: 6px 0 4px;
  animation: fadeUp 0.7s ease both;
}
.map-title {
  font-size: 30px;
  margin: 0;
  color: #fff;
  letter-spacing: 0.3px;
}
.map-tagline {
  margin: 4px 0 0;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Expanding floor stack ----------
   The three floors start collapsed in the middle, then separate:
   floor 1 (ground) at the bottom, 2 in the middle, 3 (roof) on top,
   with NO overlap between them in the final state.
   --floor-gap pulls the (transparent) image edges together; make it
   more negative to tighten the stack, 0 to spread it out. */
.floor-stack {
  --floor-gap: -13%;
  max-width: 560px;
  margin: 6px auto 0;
}

.floor {
  position: relative;
  opacity: 0;
  /* smooth, soft settle */
  animation: floorExpand 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}
.floor + .floor { margin-top: var(--floor-gap); }

/* Roof (top) and Ground (bottom) start together and expand outward
   symmetrically; the middle floor just eases in. */
.floor.pos-top    { --from: 116%;  z-index: 3; }
.floor.pos-mid    { --from: 0%;    z-index: 2; }
.floor.pos-bottom { --from: -116%; z-index: 1; }

.floor-media {
  position: relative;     /* positioning context for the markers */
}
.floor-media img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.35));
}

@keyframes floorExpand {
  0%   { opacity: 0; transform: translateY(var(--from)) scale(0.97); }
  18%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .floor { opacity: 1; animation: none; }
}

/* Overlay sits exactly over the image; markers are placed by % (x/y) */
.marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;       /* empty areas let touches pass through */
}

/* .marker = positioned box (handles location only, no scale animation).
   .marker-body = inner element that animates: cascade-in on load, then a
   gentle continuous pulse. Keeping them on separate elements lets the two
   transforms compose without fighting. */
.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  text-decoration: none;
  display: block;
  width: clamp(24px, 6.3vw, 32px);
  height: clamp(24px, 6.3vw, 32px);
}
.marker.is-info { cursor: default; }

.marker-body {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
  animation:
    markerPop 0.4s ease var(--pop-delay, 0s) both,
    markerPulse 3.2s ease-in-out var(--pulse-delay, 0s) infinite;
}

.marker-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}

/* Number badge (top-right corner of icon markers) */
.marker-num {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--deep);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* A pin marker = number only, no icon artwork (the circle is the body) */
.marker.is-pin .marker-body {
  background: var(--deep);
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
}
.marker.is-pin .marker-num {
  position: static;
  top: auto;
  right: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
}

@keyframes markerPop {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes markerPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.09); }
}

@media (prefers-reduced-motion: reduce) {
  .floor-image.is-in, .floor-tabs, .map-intro { animation: none; }
  .marker-body { animation: none; opacity: 1; }
}

.home {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.home-title {
  font-size: 26px;
  color: var(--deep);
  margin: 8px 0 18px;
}

.home-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(11, 61, 92, 0.06);
}

.exhibit-item + .exhibit-item .exhibit-link {
  border-top: 1px solid var(--line);
}

.exhibit-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px;
  text-decoration: none;
  color: var(--text);
  min-height: 44px;
}
.exhibit-link:active { background: var(--bg); }

/* Photo thumbnail on each row */
.exhibit-thumb {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--deep);
  display: block;
}

.exhibit-name {
  flex: 1 1 auto;
  font-size: 17px;
  line-height: 1.3;
}
/* the number, now inline in the text */
.exhibit-no {
  font-weight: 700;
  color: var(--deep);
  margin-right: 6px;
}

.go {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
}

/* Sub-exhibits (11a, 13b, 30c …) sit indented, with a smaller thumb */
.exhibit-item.is-sub .exhibit-link { padding-left: 24px; }
.exhibit-item.is-sub .exhibit-thumb {
  width: 44px;
  height: 44px;
}
.exhibit-item.is-sub .exhibit-name {
  font-size: 16px;
  color: var(--muted);
}
.exhibit-item.is-sub .exhibit-no { color: var(--teal); }

/* ---------- Larger screens ---------- */
@media (min-width: 700px) {
  .exhibit-title { font-size: 32px; }
  #exhibitText { font-size: 18px; }
}
