/* Styles for index.html. Classes used by js/render.js are in the "Results" sections. */

:root {
  --text: #202124;
  --muted: #4d5156;
  --link: #1a0dab;
  --border: #dfe1e5;
  --bg-soft: #f8f9fa;
  --blue: #4285f4;
  --red: #ea4335;
  --yellow: #fbbc05;
  --green: #34a853;
  --font: Arial, Helvetica, sans-serif;
  /* Desktop left edge of tabs + results; the header logo box is sized so the search box lines up */
  --content-left: 220px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
}

[hidden] { display: none; }

/* ---------- Logo (image: assets/images/logo.svg) ---------- */
.logo { display: block; margin: 0; line-height: 0; user-select: none; }
.logo img { display: block; width: auto; }
.logo-large { margin-bottom: 28px; }
.logo-large img { height: 98px; }
/* Doodle in place of the logo (js/doodle.js): natural shape, capped so the search box stays in view */
.logo-doodle img { height: auto; max-height: 200px; max-width: min(100%, 560px); }
/* Results-page header: small doodle in the logo slot */
.logo-small.logo-doodle img { height: auto; max-height: 44px; max-width: 100%; }
/* 24px header padding + this width + 32px gap = --content-left, so the box starts where results do */
.logo-small { flex-shrink: 0; width: calc(var(--content-left) - 56px); }
.logo-small img { height: 31px; }

/* ---------- Search box (shared by both views) ---------- */
.search-form { width: 100%; }

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #fff;
}

.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-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  font-size: 16px;
  font-family: var(--font);
  background: transparent;
}

.search-icon { width: 20px; height: 20px; fill: #9aa0a6; flex-shrink: 0; }

.icon-button { display: flex; padding: 0; border: 0; background: none; cursor: pointer; }
.icon-button .search-icon { fill: var(--blue); }

/* ---------- Home view ---------- */
/* ---------- Top bar (index.html home view + images.html) ---------- */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  padding: 0 16px 0 22px;
}

.top-right { display: flex; align-items: center; gap: 15px; }
/* Keeps the right group on the right (the top bar has no left group) */
.top-right { margin-left: auto; }

.top-item { color: #1f1f1f; font-size: 13px; text-decoration: none; padding: 0 5px; }

/* Hover: purple + underline, links only */
.top-link:hover { color: #681da8; text-decoration: underline; }

.apps-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.apps-button svg { width: 24px; height: 24px; fill: #444746; }
.apps-button:hover { background: #f1f3f4; }

/* Sign in is a link to dashboard.html (index.html, images.html), styled as a pill button */
.sign-in {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 20px;
  background: #0b57d0;
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

/* Images page: small "Images" label under the logo */
.logo-images { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 28px; }
.logo-images .logo-large { margin-bottom: 0; }
/* margin-bottom lifts the label from the logo's descender space up to the letter baseline */
.logo-subtitle { color: #5f6368; font-size: 22px; font-weight: 400; margin-bottom: 21px; }

/* position: relative anchors .top-bar to the home view */
.home { position: relative; }

/* :not([hidden]) so the flex display never overrides the [hidden] attribute set by js/app.js */
.home:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 22vh 20px 0;
}

.home .search-form { max-width: 692px; }

/* Home search box: magnifier on the left; mic, image and "AI Mode" on the right */
.home-box {
  height: 52px;
  gap: 4px;
  padding: 0 8px 0 10px;
  border-color: #dadce0;
  border-radius: 26px;
  box-shadow: 0 2px 8px rgba(32, 33, 36, 0.12);
}

.home-box:hover,
.home-box:focus-within {
  border-color: #dadce0;
  box-shadow: 0 2px 10px rgba(32, 33, 36, 0.2);
}

.home-box input { padding: 0 8px; }

/* Magnifier at the left of the home boxes (index.html dark grey, images.html light grey) */
.home-box > .search-icon { margin: 0 2px 0 10px; }
.home-box > .search-icon-dark { width: 24px; height: 24px; fill: #5f6368; }
.home-box input::placeholder { color: #5f6368; opacity: 1; }

.box-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.box-icon svg { width: 24px; height: 24px; fill: #1f1f1f; }
.box-icon:hover { background: #f1f3f4; }

.ai-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  margin-left: 8px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 18px;
  background: #f1f3f4;
  color: #1f1f1f;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
}

.ai-mode svg { width: 20px; height: 20px; fill: #1f1f1f; }
.ai-mode:hover { background: #e8eaed; }

.home-buttons { display: flex; justify-content: center; gap: 12px; margin-top: 30px; }

/* Shared by the <a> (Google Search) and the <button> (I'm Feeling Lucky) */
.home-button {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  height: 36px;
  border: 1px solid var(--bg-soft);
  border-radius: 8px;
  background: var(--bg-soft);
  color: #3c4043;
  font-size: 14px;
  font-family: var(--font);
  text-decoration: none;
  cursor: pointer;
}

.home-button:hover { border-color: var(--border); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); }

/* ---------- Results header + tabs ---------- */
.results-header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 20px 24px 12px;
}

.results-header .search-form { max-width: 690px; }

.tabs {
  display: flex;
  gap: 26px;
  padding: 0 24px 0 var(--content-left);
  border-bottom: 1px solid #ebebeb;
  overflow-x: auto;
  scrollbar-width: none;
}

/* <a> tabs switch results; <span> tabs (AI Mode, Videos, Shopping, Books) are labels only */
.tab {
  position: relative;
  padding: 14px 0 12px;
  color: #70757a;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
  cursor: default;
}

a.tab { cursor: pointer; }
a.tab:hover { color: #1f1f1f; }

/* Active tab: dark text + thick rounded underline */
.tab.active { color: #1f1f1f; font-weight: 500; }
.tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: #1f1f1f;
}

/* ---------- Results (markup from js/render.js) ---------- */
.results { padding: 8px 24px 48px var(--content-left); }
.results[aria-busy='true'] { opacity: 0.5; }

.all-layout { display: flex; gap: 64px; align-items: flex-start; }
/* min-width: 0 lets long URLs/snippets wrap instead of widening the column */
.web-results { max-width: 652px; flex: 1; min-width: 0; }

.stats { color: #70757a; font-size: 14px; margin: 8px 0 20px; }
.suggestion { font-size: 18px; color: #c5221f; margin: 0 0 20px; }
.suggestion a { color: var(--link); }

.result { margin-bottom: 30px; max-width: 652px; }
.result-link { text-decoration: none; display: block; }
.result-url { color: #202124; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-title { color: var(--link); font-size: 20px; font-weight: 400; margin: 4px 0; line-height: 1.3; }
.result-link:hover .result-title { text-decoration: underline; }
.result-snippet,
.result-meta { color: var(--muted); font-size: 14px; line-height: 1.58; margin: 0; }
/* Unbroken runs (long links in snippets) wrap instead of pushing the page wider */
.result-snippet { overflow-wrap: anywhere; }
.result-meta a { color: var(--muted); }

/* Web result header (js/render.js webItem): round icon, site name over URL, "..." button */
.web-site { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.web-favicon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid #ecedef;
  border-radius: 50%;
  background: #f1f3f4;
  overflow: hidden;
}
.web-favicon img { width: 18px; height: 18px; }
.web-site-text { display: flex; flex-direction: column; min-width: 0; text-decoration: none; }
.web-site-name { color: #202124; font-size: 14px; line-height: 20px; }
.web-site-url { color: #4d5156; font-size: 12px; line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-menu { display: flex; flex-shrink: 0; padding: 4px; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.web-menu svg { width: 18px; height: 18px; fill: #4d5156; }
.web-menu:hover { background: #f1f3f4; }
.web-item .result-title { margin-top: 0; }
.web-read-more { color: #4d5156; }

/* Invisible marker at the end of the list; reaching it loads more (js/infinite-scroll.js) */
.scroll-sentinel { height: 1px; }

.panel {
  width: 370px;
  flex-shrink: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.panel-image { display: block; max-width: 100%; max-height: 220px; margin: 0 auto 12px; border-radius: 6px; }
.panel-title { font-size: 26px; font-weight: 400; margin: 0 0 12px; }
.panel-text { font-size: 14px; line-height: 1.58; color: var(--muted); margin: 0 0 8px; }
.panel-source { font-size: 14px; color: var(--link); }

/* Related-search chips above the image grid (filled by js/app.js fillChips) */
.chips-row { position: relative; margin: 16px 0 24px; min-height: 48px; }
.chips { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; padding-right: 48px; }

.chip {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 48px;
  padding-right: 18px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  overflow: hidden;
  color: #1f1f1f;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.chip:hover { background: var(--bg-soft); }
.chip img { width: 48px; height: 48px; object-fit: cover; margin-right: 14px; }

/* ">" button over a white fade at the right end of the chip row */
.chips-next {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 72px;
  height: 48px;
  padding: 0;
  border: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff 55%);
  cursor: pointer;
}

.chips-next svg { width: 24px; height: 24px; fill: #5f6368; }

/* Masonry grid: CSS columns keep each image at its own aspect ratio */
.image-grid { columns: 4 220px; column-gap: 18px; }

.image-tile {
  display: block;
  break-inside: avoid;
  margin-bottom: 20px;
  color: #1f1f1f;
  text-decoration: none;
}

.image-tile > img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: var(--bg-soft);
}

.image-title {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-tile:hover .image-title { text-decoration: underline; }

.image-source { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: #5f6368; font-size: 13px; }
.image-source img { width: 16px; height: 16px; border-radius: 3px; }

.message { padding-top: 24px; font-size: 16px; overflow-wrap: anywhere; }

.pager { display: flex; gap: 24px; align-items: center; padding: 16px 0; font-size: 14px; color: #70757a; }
.pager a { color: var(--link); }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .tabs, .results { padding-left: 16px; padding-right: 16px; }
  .results-header { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
  .all-layout { flex-direction: column-reverse; align-items: stretch; gap: 24px; }
  .panel { width: 100%; }
  .logo-large img { height: 67px; }
  .logo-doodle img { height: auto; max-height: 160px; } /* doodles keep their shape on phones (wins over 67px above) */
  .logo-subtitle { margin-bottom: 14px; }
}

/* Phones: tighten the top bar so Gmail, Images, apps and Sign in fit on one line */
@media (max-width: 480px) {
  .top-bar { padding: 0 8px 0 10px; }
  .top-right { gap: 2px; }
  .top-item { padding: 0 4px; white-space: nowrap; }
  .top-bar .sign-in { padding: 0 12px; }
}

/* Small phones (360px wide): smaller apps button and Sign in padding win the last few pixels */
@media (max-width: 380px) {
  .top-bar .apps-button { width: 32px; height: 32px; }
  .top-bar .sign-in { padding: 0 10px; }
  .top-item { padding: 0 3px; }
}

/* ---------- Results header icons (index.html results header; .tab-images toggled by js/app.js) ----------
   Desktop All/News: logo | box [query, X, divider, mic, lens] | settings, share, apps, Sign in
   Desktop Images:   logo | box [query, X, divider, mic, lens, search] | settings, apps, Sign in
   Phones:           All/News: logo above box [query, X];  Images: box [logo mark, query, X] | settings, apps, Sign in */
.img-only { display: none; }
.tab-images .img-only { display: flex; align-items: center; }
.tab-images .logo-mark { display: none; }
.tab-images .tab.img-only { display: inline-block; }
.tab-images .not-images { display: none; }

.results-header { padding-right: 16px; }
.results-header .search-box { gap: 4px; padding-right: 6px; }
.results-header .box-icon { display: flex; align-items: center; }
.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }
/* Search button shows on the Images tab only */
.results-header .submit-button { display: none; }
.tab-images .results-header .submit-button { display: flex; }
/* Let the box shrink on narrow screens: width 0 drops the input's built-in minimum width, flex: 1 regrows it */
.results-header .search-form { flex: 1; min-width: 0; }
#results-input { width: 0; }
.tab-images .results { padding: 8px 16px 48px; }

/* Browser's own clear "x" would duplicate our X button */
#results-input::-webkit-search-cancel-button { appearance: none; }

.box-divider { width: 1px; height: 28px; margin: 0 6px; background: #dadce0; }
.clear-button svg { fill: #1f1f1f; }
.submit-button { width: 40px; height: 40px; align-items: center; justify-content: center; }
.tab-images .submit-button .search-icon { width: 24px; height: 24px; fill: #1f1f1f; }

/* Logo mark (assets/images/logo-mark.svg) inside the mobile Images box */
.logo-mark { flex-shrink: 0; line-height: 0; }
.logo-mark img { width: 26px; height: 26px; }

/* "More" and "Tools" get a small down caret */
.tab-menu::after {
  content: '';
  display: inline-block;
  margin-left: 6px;
  vertical-align: 2px;
  border: 4px solid transparent;
  border-top-color: currentColor;
  border-bottom-width: 0;
}

@media (max-width: 900px) {
  .results-header .desktop-only,
  .results-header .header-actions { display: none; }
  .tab-images .results-header .header-actions { display: flex; }
  .tab-images .results-header { flex-direction: row; align-items: center; gap: 12px; }
  .tab-images .results-header > .logo,
  .tab-images .results-header .submit-button { display: none; }
  .tab-images .logo-mark { display: block; }
  .tab-images .results-header .search-box { height: 50px; padding-left: 14px; gap: 8px; }
  .tab-images .header-actions { gap: 4px; }
  .tab-images .image-grid { columns: 2; column-gap: 12px; }
}
