/* =====================================================================
   The Library Tank — aquarium.css
   ===================================================================== */

/* --- Container & Canvas --- */

.aquarium-container {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #0a1628;
  touch-action: pan-y;
}

#aquarium-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* --- Loading State --- */

.aquarium-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: #0a1628;
}

.aquarium-loading.hidden {
  display: none;
}

.aquarium-loading-text {
  font-family: 'Caveat', 'Patrick Hand', cursive, serif;
  font-size: 1.3rem;
  color: rgba(255, 245, 220, 0.6);
  animation: aquarium-pulse 2s ease-in-out infinite;
}

@keyframes aquarium-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* --- In-Tank Loading Notice --- */

.aquarium-tank-notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.8s ease;
}

.aquarium-tank-notice.fade-out {
  opacity: 0;
}

.tank-notice-text {
  font-family: 'Caveat', 'Patrick Hand', cursive, serif;
  font-size: 1.8rem;
  color: rgba(90, 70, 50, 0.6);
  text-shadow: 0 1px 3px rgba(255, 245, 220, 0.3);
  animation: aquarium-pulse 2.5s ease-in-out infinite;
}

/* --- Diagnostic Download Button --- */

.aquarium-diag {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 245, 220, 0.12);
  border: 1px solid rgba(255, 245, 220, 0.15);
  color: rgba(255, 245, 220, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
  z-index: 15;
}

.aquarium-diag:hover {
  opacity: 1;
  background: rgba(255, 245, 220, 0.2);
  color: rgba(255, 245, 220, 0.7);
}

/* --- Librarian Sign --- */

.aquarium-sign {
  position: absolute;
  top: 12px;
  left: 12px;
  /* top/left are overridden by JS to track tank position during pan */
  background: rgba(255, 248, 230, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 14px 18px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.82rem;
  line-height: 1.75;
  color: #2a2218;
  letter-spacing: 0.01em;
  transform: rotate(-1.5deg);
  box-shadow: 2px 3px 12px rgba(0, 0, 0, 0.18);
  max-width: 190px;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.aquarium-sign p {
  margin: 0;
}

.sign-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 0.78rem;
  text-align: center;
  letter-spacing: 0.03em;
  margin-bottom: 6px !important;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.sign-quirk {
  margin-top: 4px !important;
  font-style: italic;
  font-size: 0.75rem;
  color: #5a4a38;
}

.aquarium-sign::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 14px;
  background: rgba(255, 220, 100, 0.7);
  border-radius: 2px;
}

/* --- Controls --- */

.aquarium-ui {
  position: absolute;
  top: 12px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 15;
  transition: opacity 0.5s ease;
}

.aquarium-control {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 245, 220, 0.2);
  border-radius: 50%;
  background: rgba(10, 22, 40, 0.6);
  backdrop-filter: blur(4px);
  color: rgba(255, 245, 220, 0.8);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.aquarium-control:hover {
  background: rgba(10, 22, 40, 0.8);
  border-color: rgba(255, 245, 220, 0.4);
}

.aquarium-control:active {
  transform: scale(0.92);
}

.aquarium-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.aquarium-control:focus-visible {
  outline: 2px solid rgba(255, 245, 220, 0.6);
  outline-offset: 2px;
}

.control-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.aquarium-back-btn {
  width: auto;
  border-radius: 22px;
  padding: 0 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* --- Tooltips --- */

.aquarium-control {
  position: relative;
}

.aquarium-control::after {
  content: attr(title);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(10, 22, 40, 0.85);
  color: rgba(255, 245, 220, 0.85);
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border: 1px solid rgba(255, 245, 220, 0.1);
}

.aquarium-control:hover::after {
  opacity: 1;
}

/* --- Confirmation Bubble --- */

.aquarium-confirm {
  position: absolute;
  z-index: 25;
  background: rgba(20, 16, 12, 0.95);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  text-align: center;
  min-width: 200px;
  max-width: 240px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: aquarium-fadeIn 0.25s ease;
}

.aquarium-confirm.hidden {
  display: none;
}

.confirm-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  color: rgba(255, 245, 220, 0.95);
  margin: 0 0 2px 0;
  font-weight: 600;
}

.confirm-species {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-style: italic;
  color: rgba(201, 168, 76, 0.6);
  margin: 0 0 8px 0;
  letter-spacing: 0.02em;
}

.confirm-flavor {
  font-family: 'Caveat', 'Patrick Hand', cursive, serif;
  font-size: 0.95rem;
  color: rgba(255, 245, 220, 0.7);
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confirm-yes,
.confirm-no {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.confirm-yes {
  background: #c9a84c;
  color: #1a1510;
  border-color: #c9a84c;
  font-weight: 600;
}

.confirm-yes:hover {
  background: #d4b45c;
}

.confirm-no {
  background: transparent;
  color: rgba(255, 245, 220, 0.6);
  border-color: rgba(255, 245, 220, 0.15);
}

.confirm-no:hover {
  color: rgba(255, 245, 220, 0.85);
  border-color: rgba(255, 245, 220, 0.3);
}

.confirm-no:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* --- Glass Tap Ripple --- */

.aquarium-ripple {
  position: absolute;
  width: 60px;
  height: 60px;
  margin-left: -30px;
  margin-top: -30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;
  animation: aquarium-rippleExpand 0.6s ease-out forwards;
  z-index: 5;
}

@keyframes aquarium-rippleExpand {
  0% {
    transform: scale(0.3);
    opacity: 1;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* --- Catchphrase Speech Bubble --- */
.creature-catchphrase {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(15, 13, 11, 0.85);
  color: #f2ece3;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 400;
  font-style: italic;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid rgba(201, 168, 76, 0.3);
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 180px;
  text-align: center;
  white-space: nowrap;
}

.creature-catchphrase.visible {
  opacity: 1;
}

.creature-catchphrase.fading {
  opacity: 0;
}

.creature-catchphrase::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  margin-left: -5px;
  border-width: 6px 5px 0;
  border-style: solid;
  border-color: rgba(15, 13, 11, 0.85) transparent transparent;
}

/* --- Reveal Overlay --- */

.aquarium-reveal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(10, 22, 40, 0.85);
  backdrop-filter: blur(8px);
  animation: aquarium-fadeIn 0.8s ease;
}

.aquarium-reveal.hidden {
  display: none;
}

.aquarium-reveal-card {
  max-width: 360px;
  width: 90%;
  padding: 28px 24px 40px;
  margin: auto 0;
  text-align: center;
}

.reveal-creature-portrait {
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle, rgba(20, 40, 60, 0.8), rgba(10, 22, 40, 0.95));
  border: 2px solid rgba(255, 245, 220, 0.1);
}

.reveal-creature-portrait canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reveal-creature-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(255, 245, 220, 0.95);
  margin: 0 0 4px 0;
  letter-spacing: 0.02em;
}

.reveal-species {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.85rem;
  font-style: italic;
  color: rgba(255, 245, 220, 0.4);
  margin: 0 0 16px 0;
  letter-spacing: 0.03em;
}

.reveal-creature-line {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  font-style: italic;
  color: rgba(255, 245, 220, 0.85);
  margin: 0 0 20px 0;
  line-height: 1.6;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Field Guide Metadata --- */

.reveal-field-guide {
  margin-bottom: 20px;
  text-align: left;
  border-top: 1px solid rgba(255, 245, 220, 0.08);
  padding: 18px 0 4px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.reveal-field-row {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  align-items: baseline;
}

.reveal-field-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 245, 220, 0.55);
  min-width: 90px;
  flex-shrink: 0;
}

.reveal-field-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.88rem;
  color: rgba(255, 245, 220, 0.8);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

.reveal-buy-link {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: #c9a84c;
  text-decoration: none;
  padding: 10px 22px;
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 8px;
  margin-bottom: 12px;
  transition: background 0.2s, border-color 0.2s;
}

.reveal-buy-link:hover {
  background: rgba(201, 168, 76, 0.1);
  border-color: #c9a84c;
}

.reveal-share-btn,
.reveal-restart-btn {
  display: block;
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 10px 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}

.reveal-share-btn {
  background: rgba(255, 245, 220, 0.1);
  color: rgba(255, 245, 220, 0.7);
}

.reveal-share-btn:hover {
  background: rgba(255, 245, 220, 0.15);
}

.reveal-restart-btn {
  background: transparent;
  color: rgba(255, 245, 220, 0.4);
  font-size: 0.8rem;
}

.reveal-restart-btn:hover {
  color: rgba(255, 245, 220, 0.6);
}

/* --- Reveal Typewriter & New Content Styles --- */

.reveal-element-hidden {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reveal-element-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-typing {
  border-right: 2px solid rgba(255, 245, 220, 0.6);
  animation: blink-caret 0.75s step-end infinite;
}

@keyframes blink-caret {
  from, to { border-color: rgba(255, 245, 220, 0.6); }
  50% { border-color: transparent; }
}

.reveal-catchphrase {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.95rem;
  font-style: italic;
  color: rgba(201, 168, 76, 0.85);
  margin: 0 0 16px 0;
  letter-spacing: 0.02em;
}

.reveal-personality {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: rgba(255, 245, 220, 0.7);
  line-height: 1.7;
  margin: 0 0 18px 0;
  padding: 12px 16px;
  background: rgba(255, 245, 220, 0.04);
  border-left: 2px solid rgba(201, 168, 76, 0.25);
  border-radius: 0 6px 6px 0;
  text-align: left;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.reveal-kindred {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.9rem;
  font-style: italic;
  color: rgba(255, 245, 220, 0.55);
  margin: 0 0 20px 0;
  letter-spacing: 0.02em;
  line-height: 1.6;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.reveal-rarity {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 10px;
  border-radius: 10px;
  margin: 0 0 12px 0;
}

.reveal-rarity-uncommon {
  color: #4a9e8e;
  border: 1px solid rgba(74, 158, 142, 0.4);
  background: rgba(74, 158, 142, 0.1);
}

.reveal-rarity-rare {
  color: #d4a043;
  border: 1px solid rgba(212, 160, 67, 0.4);
  background: rgba(212, 160, 67, 0.1);
}

.reveal-rarity-mythic {
  color: #b088f9;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.15);
}

.reveal-flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0.12;
  z-index: 28;
  animation: reveal-flash-anim 150ms ease-out forwards;
  pointer-events: none;
}

@keyframes reveal-flash-anim {
  from { opacity: 0.12; }
  to { opacity: 0; }
}

.reveal-share-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.reveal-share-actions .reveal-share-btn {
  flex: 1;
  margin-top: 0;
}

.reveal-share-video-btn {
  background: rgba(139, 92, 246, 0.15) !important;
  color: rgba(200, 180, 255, 0.8) !important;
  border: 1px solid rgba(139, 92, 246, 0.3) !important;
}

.reveal-share-video-btn:hover {
  background: rgba(139, 92, 246, 0.25) !important;
}

/* --- Animations --- */

@keyframes aquarium-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Responsive --- */

@media (max-width: 480px) {
  .aquarium-ui {
    right: 0;
  }

  .aquarium-sign {
    top: 10px;
    left: 10px;
    font-size: 0.75rem;
    max-width: 155px;
    padding: 10px 14px;
  }

  .aquarium-control::after {
    display: none;
  }

  .aquarium-control {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .aquarium-back-btn {
    width: auto;
    height: auto;
    padding: 8px 14px;
    font-size: 0.72rem;
  }

  .aquarium-reveal-card {
    padding: 20px 16px;
  }

  .reveal-creature-name {
    font-size: 1.25rem;
  }

  .reveal-creature-portrait {
    width: 160px;
    height: 160px;
  }

  .reveal-personality {
    font-size: 0.78rem;
    padding: 10px 12px;
  }

  .reveal-catchphrase {
    font-size: 0.85rem;
  }

  .reveal-share-actions {
    flex-direction: column;
  }
}

/* --- Hide global UI when aquarium is active --- */

body.aquarium-active .view-all-btn,
body.aquarium-active .disclosure,
body.aquarium-active .help-fab,
body.aquarium-active #faq-widget,
body.aquarium-active #breadcrumbs {
  display: none !important;
}

/* --- Screen active state (overrides main styles.css .screen rules) --- */

#screen-aquarium {
  padding: 0;
  max-width: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  transform: none;
  opacity: 1;
}

#screen-aquarium.active {
  display: block;
}
