@import url('fonts.css');

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

:root {
  --blue: #1a73e8;
  --blue-light: #e8f0fe;
  --green: #01875f;
  --green-light: #e6f4ea;
  --text: #202124;
  --text-2: #5f6368;
  --border: #e8eaed;
  --bg: #f8f9fa;
  --teal: #3be5c7;
  --teal-glow: rgba(59,229,199,0.55);
  --radius: 12px;
}

body {
  font-family: 'Google Sans', 'Roboto', Helvetica, Arial, sans-serif;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

/* ──────────────────────────────────────────
   HEADER
────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text);
  margin-right: 16px;
}

.header-logo svg { flex-shrink: 0; }

.header-logo-text {
  font-size: 18px;
  font-weight: 500;
  color: #202124;
  letter-spacing: -.2px;
  white-space: nowrap;
  font-family: 'Google Sans', 'Product Sans', 'Roboto', sans-serif;
}

/* Nav tabs — desktop */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 16px;
  flex-shrink: 0;
}

.header-nav-link {
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.header-nav-link:hover { background: #f1f3f4; color: var(--text); }
.header-nav-link.active { background: var(--green-light); color: var(--green); }

/* Search bar — hidden by default, shown when .search-active on header */
.header-search {
  display: none;
  flex: 1;
  align-items: center;
  gap: 8px;
  max-width: 720px;
  margin: 0 8px;
  position: relative;
}

.header.search-active .header-search {
  display: flex;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 690px;
  max-width: calc(100% - 320px);
}
.header.search-active .header-nav    { display: none; }
.header.search-active #searchOpenBtn { display: none; }
.header.search-active .header-search-back { display: none; }

.header-search-back {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 50%; border: none; background: transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.header-search-back:hover { background: #f1f3f4; }

.header-search-form {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f1f3f4;
  border-radius: 24px;
  padding: 0 12px 0 16px;
  height: 46px;
  border: 1px solid transparent;
  transition: background .15s, box-shadow .15s, border-radius .15s;
}

.header-search-form:focus-within {
  background: #fff;
  box-shadow: 0 1px 6px rgba(32,33,36,.28);
  border-color: #dfe1e5;
}

.header-search-form.dropdown-open {
  border-radius: 24px 24px 0 0;
  box-shadow: 0 0 0 1px #dfe1e5;
  border-bottom-color: transparent;
}

.header-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  min-width: 0;
}

.header-search-input::placeholder { color: var(--text-2); }
.header-search-input::-webkit-search-cancel-button { display: none; }

.header-search-clear {
  width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.header-search-clear:hover { background: #e8eaed; }

/* Dropdown suggestions */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% - 1px);
  left: 0; right: 0;
  background: #fff;
  box-shadow: 0 4px 6px rgba(32,33,36,.28);
  border-radius: 0 0 24px 24px;
  border: 1px solid #dfe1e5;
  border-top: none;
  overflow: hidden;
  z-index: 200;
  padding-bottom: 8px;
}
.search-dropdown.active { display: block; }

.search-suggestion-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background .1s;
}
.search-suggestion-row:hover { background: var(--bg); }
.search-suggestion-row svg { flex-shrink: 0; color: #5f6368; }
.search-suggestion-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.search-suggestion-text strong { font-weight: 600; color: var(--text); }

/* Right icons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.header-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background .15s;
}

.header-icon-btn:hover { background: #f1f3f4; }

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────
   DEVICE CHIPS
────────────────────────────────────────── */
.device-chips {
  display: flex;
  gap: 8px;
  padding: 16px 24px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.device-chips::-webkit-scrollbar { display: none; }

.device-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border: 1px solid #dadce0;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: #fff;
  white-space: nowrap;
  transition: background .15s;
}

.device-chip .mi { font-size: 16px; }
.device-chip:hover { background: var(--bg); }
.device-chip.active { background: var(--green-light); border-color: var(--green); color: var(--green); }
.device-chip.active .mi { color: var(--green); }

/* ──────────────────────────────────────────
   MAIN LAYOUT
────────────────────────────────────────── */
main {
  max-width: 1392px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ──────────────────────────────────────────
   SECTION HEADER
────────────────────────────────────────── */
.sec-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 24px 0 14px;
}

.sec-title { font-size: 20px; font-weight: 400; color: var(--text); }
.sec-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.sec-more {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--blue);
  flex-shrink: 0;
}

.sec-more .mi { font-size: 18px; }

/* ──────────────────────────────────────────
   FEATURED CAROUSEL (Google Play style)
────────────────────────────────────────── */
.feat-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  /* bleed to edges */
  margin: 0 -24px;
  padding-left: 24px;
  padding-right: 24px;
}

.feat-row::-webkit-scrollbar { display: none; }

.feat-card {
  flex: 0 0 500px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  background: #000;
  transition: box-shadow .2s;
}

.feat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.15); }

.feat-card__art {
  position: relative;
  height: 280px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.feat-card__art::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 50%);
}

.feat-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  color: #fff;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 4px;
}

.feat-card__text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px 14px;
  z-index: 2;
}

.feat-card__title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feat-card__sub {
  font-size: 13px;
  color: rgba(255,255,255,.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feat-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  background: #fff;
  flex-shrink: 0;
}

.feat-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #f1f3f4;
}

.feat-card__info { flex: 1; min-width: 0; }

.feat-card__name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feat-card__dev {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feat-card__btn {
  flex-shrink: 0;
  background: #1f1f1f;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background .15s;
}

.feat-card__btn:hover { background: #3c3c3c; }

/* ──────────────────────────────────────────
   ICON ROW (horizontal scroll)
────────────────────────────────────────── */
.icon-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.icon-row::-webkit-scrollbar { display: none; }

.icon-tile {
  flex: 0 0 162px;
  cursor: pointer;
  display: block;
  text-decoration: none;
  color: var(--text);
}

.icon-tile img {
  width: 162px;
  height: 162px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}

.icon-tile-name {
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.icon-tile-rating {
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 3px;
}

.icon-tile-rating .mi { font-size: 12px; color: #f29900; }

/* ──────────────────────────────────────────
   TOP CHARTS (tabbed)
────────────────────────────────────────── */
.top-charts-wrap { }

.chart-tabs-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.chart-tab-btn {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid transparent;
  border-radius: 9999px;
  background: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.chart-tab-btn:hover { background: var(--bg); color: var(--text); }
.chart-tab-btn.active { background: var(--green-light); color: var(--green); }

.chart-panel { display: none; }
.chart-panel.active { display: block; }

.chart-list-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
}

@media (max-width: 900px) { .chart-list-3col { grid-template-columns: 1fr; } }

.chart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}

.chart-item:nth-last-child(-n+3) { border-bottom: none; }
.chart-item:hover { background: var(--bg); }

.chart-rank {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.chart-item img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.chart-info { flex: 1; min-width: 0; }

.chart-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chart-sub {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-rating {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
  white-space: nowrap;
}

.chart-rating .mi { font-size: 13px; color: #f29900; }

/* ──────────────────────────────────────────
   SCREENSHOT CARD GRID
────────────────────────────────────────── */
.ss-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 900px) { .ss-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .ss-grid { grid-template-columns: 1fr; } }

.ss-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: box-shadow .2s;
}

.ss-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.1); }

.ss-card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: #f1f3f4;
}

.ss-card-play {
  position: relative;
}

.ss-card-play::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ss-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
}

.ss-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.ss-card-info .name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 200px;
}

.ss-card-info .sub {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ss-card-info .sub .mi { font-size: 11px; color: #f29900; }

/* ──────────────────────────────────────────
   FOOTER
────────────────────────────────────────── */
footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  font-size: 12px;
  color: var(--text-2);
}

.footer-inner {
  max-width: 1392px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
}

.footer-col h4 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}

.footer-col a {
  display: block;
  color: var(--text-2);
  font-size: 12px;
  margin-bottom: 8px;
}

.footer-col a:hover { color: var(--blue); }

.footer-bottom {
  max-width: 1392px;
  margin: 20px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-2);
}

.footer-bottom a { color: var(--text-2); }
.footer-bottom a:hover { text-decoration: underline; }


/* ──────────────────────────────────────────
   BOTTOM NAV (mobile only)
────────────────────────────────────────── */
.bottom-nav {
  display: none;
}

@media (max-width: 600px) {
  /* Featured cards: 1 card = full screen width, snap scroll */
  .feat-row {
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    gap: 12px;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 16px;
  }
  .feat-card {
    flex: 0 0 calc(100vw - 32px);
    border-radius: 16px;
    scroll-snap-align: center;
  }
  .feat-card__art { background-position: center center; }
  .feat-card__art { height: 260px; }

  /* Header becomes 2-row layout like Google Play mobile */
  .header {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px 0;
    gap: 0;
    align-items: center;
  }
  .header-logo { flex: 1; margin-right: 0; order: 1; }
  .header-logo-text { display: block; font-size: 16px; }
  .header-search { order: 2; }
  .header-actions { margin-left: 0; gap: 0; order: 3; }
  .header-icon-btn { display: flex; width: 36px; height: 36px; }
  /* Nav wraps to row 2 */
  .header-nav { order: 4; }

  /* Nav wraps to second row */
  .header-nav {
    display: flex;
    flex-basis: 100%;
    margin: 0 -12px;
    padding: 0 12px;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    margin-right: 0;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .header-nav-link {
    padding: 10px 16px;
    border-radius: 0;
    font-size: 13px;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
  }
  .header-nav-link:hover { background: transparent; }
  .header-nav-link.active {
    background: transparent;
    border-bottom-color: var(--green);
    color: var(--green);
  }

  /* Search bar */
  .header-search { margin: 0 4px; }
  .header-search-input { font-size: 14px; }
  .header.search-active .header-search {
    position: static;
    transform: none;
    width: auto;
    max-width: none;
    flex: 1;
  }
  .header.search-active .header-search-back { display: flex; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: #fff;
    border-top: 1px solid var(--border);
    height: 56px;
  }

  .bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    padding: 6px 0 4px;
    transition: color .15s;
  }

  .bottom-nav-link .mi {
    font-size: 22px;
  }

  .bottom-nav-link.active {
    color: var(--green);
  }

  .bottom-nav-link.active .mi {
    color: var(--green);
  }

  /* Push page content up so footer doesn't cover it */
  main { padding-bottom: 72px; }
  footer { margin-bottom: 56px; }
}

/* Material Icons alias */
.mi {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
}
