@tailwind base;
@tailwind components;
@tailwind utilities;

/* =========================
   Hydration guard (GLOBAL)
========================= */
.no-hydration [data-field] {
  visibility: hidden;
}

[data-field] {
  transition: opacity 0.15s ease;
}

html:not(.no-hydration) [data-field] {
  visibility: visible;
  opacity: 1;
}

/* =========================
   PageChrome – FIXED UI ONLY
   (Theme + Share)
========================= */

.page-chrome-top {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 1000;
}

/* Buttons */
.theme-toggle,
[data-surface="shareButton"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  
  /* --- SYSTEM CHROME STYLE (Matches Footer) --- */
  /* 1. Use the Footer variable so it looks like "System UI" */
  background: var(--footer-bg);
  
  /* 2. Apply standard system blur (Matches Footer) */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  
  /* 3. Use the shared border variable */
  border: 1px solid var(--header-border); 
  /* -------------------------------------------- */
  
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  
  transition: all 0.2s ease;
}

.theme-toggle {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

[data-surface="shareButton"]:hover {
  /* Slight darken on hover */
  background: var(--bg-soft); 
}

/* Hydration safety */
.no-hydration .page-chrome-top {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 480px) {
  .theme-toggle,
  [data-surface="shareButton"] {
    padding: 0 12px;
    font-size: 14px;
  }
}

/* =========================
   Reserve space for fixed PageChrome
========================= */
:root {
  --page-chrome-height: 44px;
}

main {
  padding-top: calc(var(--page-chrome-height) + 2px);
}

@media (max-width: 480px) {
  main {
    padding-top: calc(var(--page-chrome-height) + 2px);
  }
}

/* =========================
   Platform Footer (Subtle)
========================= */

.platform-footer {
  margin-top: 8px;
  padding: 20px 16px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.platform-footer-cta {
  margin-bottom: 6px;
  line-height: 1.4;
}

.platform-footer-cta a {
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}

.platform-footer-cta a:hover {
  text-decoration: underline;
}

.platform-footer-links {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.platform-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.platform-footer-links a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .platform-footer {
    font-size: 12px;
    padding-bottom: 28px;
  }
}

/* ===========================
   Share Modal
   =========================== */

.share-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000; /* Above PageChrome (z-index: 1000) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.share-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.share-modal {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.share-modal-overlay.is-open .share-modal {
  transform: scale(1);
}

.share-modal-header {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  padding-right: 32px; /* Space for close button */
}

.share-modal-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.share-modal-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-align: left;
}

.share-modal-button:hover {
  background: var(--bg-soft);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.share-modal-button:active {
  transform: translateY(0);
}

.share-modal-button svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.share-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.share-modal-close:hover {
  background: var(--bg-soft);
  color: var(--text-main);
}

.share-copy-feedback {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.share-copy-feedback.show {
  opacity: 1;
}

@media (max-width: 480px) {
  .share-modal {
    max-width: 100%;
    margin: 0 16px;
  }

  .share-modal-buttons {
    grid-template-columns: 1fr;
  }
}
