/* Homepage Tiles - PPGQ IQ-USP */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #000;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  /* Safe area insets for notch devices */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.homepage {
  height: 100vh;
  height: 100dvh;
  height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  width: 100vw;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Search Box - estilo Google */
.search-box {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  background: #fff;
  padding: 0 20px;
  height: 46px;
  width: 90%;
  max-width: 584px;
  border: 1px solid #dfe1e5;
  border-radius: 24px;
  box-shadow: none;
  transition: box-shadow 0.2s ease;
}

.search-box:hover,
.search-box:focus-within {
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  border-color: rgba(223, 225, 229, 0);
}

.search-icon {
  color: #9aa0a6;
  flex-shrink: 0;
  margin-right: 13px;
  width: 20px;
  height: 20px;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  background: transparent;
  color: #202124;
  line-height: 24px;
}

.search-box input::placeholder {
  color: #9aa0a6;
}

/* Voice Search Button - 44x44 touch target */
.voice-search-btn {
  background: none;
  border: none;
  padding: 0;
  margin-left: 8px;
  cursor: pointer;
  color: #4285f4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  transition: color 0.2s ease;
}

.voice-search-btn svg {
  width: 24px;
  height: 24px;
}

.voice-search-btn:hover {
  color: #1a73e8;
}

.voice-search-btn.listening {
  color: #ea4335;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.voice-search-btn.unsupported {
  color: #dadce0;
  cursor: not-allowed;
}

.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: -1px;
  right: -1px;
  background: #fff;
  border: 1px solid #dfe1e5;
  border-top: 1px solid #e8eaed;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 6px rgba(32, 33, 36, 0.28);
  max-height: min(400px, 50vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px 0;
}

/* Quando resultados estão visíveis, ajusta o container */
.search-box:has(.search-results[style*="block"]) {
  border-radius: 24px 24px 0 0;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
}

.search-result {
  display: flex;
  align-items: center;
  padding: 8px 20px;
  text-decoration: none;
  color: #202124;
  font-size: 14px;
  transition: background 0.1s;
}

.search-result:hover {
  background: #f1f3f4;
}

.search-result-title {
  font-weight: 400;
}

.search-no-results {
  padding: 12px 20px;
  color: #70757a;
  text-align: center;
  font-size: 14px;
}

/* Grid Container - 4 columns x 2 rows = 8 cells */
.tiles-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* Base Tile */
.tile {
  position: relative;
  overflow: hidden;
}

/* Wide/Tall classes are just for styling (icon/font size), not for grid positioning */

.tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  padding: 1.5rem;
  text-align: center;
}


/* Tile Content */
.tile-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.95;
}


/* Logo */
.tile-logo {
  width: 17.5vw;
  max-height: 30vh;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.tile-inner:hover .tile-logo {
  transform: scale(1.08);
}

/* Touch feedback for mobile */
.tile-inner:active {
  transform: scale(0.97);
  opacity: 0.9;
  transition: transform 0.1s, opacity 0.1s;
}

.tile-logo-white {
  filter: brightness(0) invert(1);
}

/* Texto - escondido */
.tile-description {
  display: none;
}

/* Mobile Layout - 2x3 grid, all tiles same size */
@media (max-width: 768px) {
  /* Search box - inline at top instead of floating */
  .search-box {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: calc(100% - 2rem);
    max-width: none;
    margin: 1rem;
    height: 44px;
    padding: 0 16px;
    flex-shrink: 0;
  }

  .search-box input {
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
  }

  .tiles-container {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    grid-template-areas: none !important;
    flex: 1;
    height: auto;
  }

  /* On mobile, reset grid-area so all tiles are 1x1 */
  .tile {
    grid-area: auto !important;
  }

  .tile-logo {
    width: 35vw;
    max-height: 18vh;
  }

  .tile-icon {
    width: 32px;
    height: 32px;
  }
}

/* Focus States for Keyboard Navigation */
.tile-inner:focus {
  outline: 3px solid #fff;
  outline-offset: -3px;
}

.tile-inner:focus:not(:focus-visible) {
  outline: none;
}

.tile-inner:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -3px;
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .tile-logo,
  .tile-description {
    transition: none;
  }

  .tile-description {
    opacity: 1;
  }
}

/* ==============================================
   Contact Modal
   ============================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  min-width: 44px;
  min-height: 44px;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-content h2 {
  margin: 0 0 1.5rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e3a5f;
  padding-right: 2rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.contact-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: #1e3a5f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-row div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contact-row strong {
  font-size: 0.85rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.contact-row span,
.contact-row a {
  font-size: 1rem;
  color: #333;
  line-height: 1.5;
}

.contact-row a {
  color: #0ea5e9;
  text-decoration: none;
}

.contact-row a:hover {
  text-decoration: underline;
}

/* Button styling to match tile link */
button.tile-inner {
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
}

/* Mobile modal - bottom sheet pattern */
@media (max-width: 576px) {
  .modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    animation: slideUp 0.3s ease-out;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-content h2 {
    font-size: 1.25rem;
  }

  .contact-row {
    gap: 0.75rem;
  }

  .contact-icon {
    width: 20px;
    height: 20px;
  }

  .contact-icon svg {
    width: 20px;
    height: 20px;
  }

  .contact-row span,
  .contact-row a {
    font-size: 0.9rem;
  }
}

@media (max-width: 768px) and (min-width: 577px) {
  .modal-content {
    padding: 1.5rem;
    border-radius: 12px;
  }

  .modal-content h2 {
    font-size: 1.25rem;
  }

  .contact-row {
    gap: 0.75rem;
  }
}
