/* ── Custom properties ── */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-card: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-link: #2a9d8f;
  --border: #d2d2d7;
  --search-bg: #f5f5f7;
  --search-border: #d2d2d7;
  --search-focus-border: #2a9d8f;
  --accent: #2a9d8f;
  --shadow: rgba(0, 0, 0, 0.08);
  --card-work: #f0f0ff;
  --card-code: #f0faf0;
  --card-3d: #f3f0ff;
  --card-other: #f5f3f0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1f25;
    --bg-secondary: #21262a;
    --bg-card: #282e34;
    --text-primary: #e1e4e8;
    --text-secondary: #8b949e;
    --text-link: #5ec4b6;
    --border: #363c42;
    --search-bg: #21262a;
    --search-border: #363c42;
    --search-focus-border: #5ec4b6;
    --accent: #5ec4b6;
    --shadow: rgba(0, 0, 0, 0.3);
    --card-work: #262838;
    --card-code: #243028;
    --card-3d: #282430;
    --card-other: #2a2824;
  }
}

/* ── Reset & base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Futura', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Search hero ── */
#search-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  padding: 2rem 1rem 1rem;
}

#search-form {
  width: 100%;
  max-width: 640px;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#search-input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1.425rem;
  border: 2px solid var(--search-border);
  border-radius: 12px;
  background: var(--search-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

#search-input:focus {
  border-color: var(--search-focus-border);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.15);
}

#search-input::placeholder {
  color: var(--text-secondary);
}

#search-engine {
  padding: 0.75rem 0.75rem;
  font-family: inherit;
  font-size: 1.2rem;
  border: 2px solid var(--search-border);
  border-radius: 12px;
  background: var(--search-bg);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  min-width: 140px;
}

/* ── Link sections ── */
#links {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.link-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px var(--shadow);
}

.link-card:nth-child(1) { background: var(--card-work); }
.link-card:nth-child(2) { background: var(--card-3d); }
.link-card:nth-child(3) { background: var(--card-code); }
.link-card:nth-child(4) { background: var(--card-other); }

.link-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.link-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.link-card li {
  padding: 0.3rem 0;
}

.link-card li a {
  font-size: 1.2rem;
}

.link-favicon {
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 0.4rem;
}

.link-card .link-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-left: 0.25rem;
}

.link-card .link-sub {
  font-size: 1.05rem;
}

.link-card .link-sub a {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.link-card h4 {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  opacity: 0.7;
}

.link-card h4:first-of-type {
  margin-top: 0;
}

/* ── Refresh button ── */
#refresh-wrap {
  text-align: center;
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

#version-info {
  font-size: 0.95rem;
  color: var(--text-secondary);
  opacity: 0.4;
}

#refresh-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity 0.2s ease, background 0.2s ease;
}

#refresh-btn:hover {
  opacity: 1;
  background: var(--border);
}

#refresh-btn.updating svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  #search-hero {
    min-height: 15vh;
    padding: 1.5rem 1rem 1rem;
  }

  .search-row {
    flex-direction: column;
  }

  #search-engine {
    min-width: unset;
    width: 100%;
  }

  #search-input {
    font-size: 1.3rem;
  }

  .link-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  #search-hero {
    min-height: 28vh;
  }
}
