/* layout.css — page-level structure: container, header, footer, grid, toolbars.
 * Owns: positioning and layout of major regions, plus responsive breakpoints.
 * Depends on: tokens.css.
 */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

/* ----- Header ----- */
header.site {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 8px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.site-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.site-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.site-title h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.site-title .deva {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}
.site-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.tagline {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 0;
  /* No max-width — let the tagline flow with the container width. */
}
.quicklinks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Tagline tail link (e.g. "About me →") */
.tagline-link {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.tagline-link:hover { text-decoration: underline; }

/* ----- Section title + sort/view toolbars ----- */
section.section-title,
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0 12px;
}
.section-title h2 {
  font-size: 16px;
  margin: 0;
  letter-spacing: -0.005em;
  font-weight: 700;
}
.section-title .count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.section-title-meta {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title-link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.section-title-link:hover { text-decoration: underline; }
.sort-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 14px;
}
.sort-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: 2px;
}

/* ----- Grid ----- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (min-width: 1000px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
@media (min-width: 1300px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }
}

/* ----- Profiles section ----- */
section.profiles {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 28px;
  content-visibility: auto;
  contain-intrinsic-block-size: 200px;
}

/* ----- Footer ----- */
footer.site {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
footer.site a { color: var(--text-muted); }
.footer-deeplinks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  font-size: 12.5px;
}
.footer-deeplinks a {
  color: var(--accent);
  font-weight: 500;
}
.footer-deeplinks-label {
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.footer-version code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  background: var(--bg-elev);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}
.footer-version a { color: inherit; text-decoration: none; }
.footer-version a:hover code { background: var(--accent-soft); color: var(--accent); }

/* ----- Larger screens ----- */
@media (min-width: 700px) {
  .container {
    padding:
      max(28px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(56px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
  }
  .site-title h1 { font-size: 26px; }
  header.site { padding-bottom: 28px; margin-bottom: 28px; }
}
