/* Layout tweaks on top of Pico classless.
   Keep this file small. Anything substantive belongs in Pico itself or a JSON field. */

:root {
  --portfolio-card-min: 320px;
  /* Title fits 3 lines (longest: Seawater-Sediment-Freshwater Salient Intrusion Simulation). */
  --project-title-min: calc(1.05rem * 1.25 * 4);
  /* Description fits 4 lines at card min-width. */
  --project-desc-min: calc(1rem * 1.65 * 5);
  /* Tech stack fits 2 wrapped lines (longest: Esgmetds). */
  --project-tech-min: calc(0.85rem * 1.65 * 2);
}

/* Pico uses tight line-height on headings (down to 1.125 on h1). That can clip
   descenders on subtitle and body copy, so we give readable text a bit more room. */
body {
  line-height: 1.25;
}

body > header {
  padding-block: 2rem;   /* top + bottom; default is ~1rem from Pico */
}

header .site-intro {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: center;
  align-items: center;
}

header .site-intro p,
main p,
.experience-list li,
.project-card p {
  line-height: 1.65;
}

.header-socials {
  margin-block-start: 0.15rem;
}

.socials-icons-only .social-link {
  gap: 0;
}

.socials-icons-only .social-link span {
  display: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.5;
}

main > section {
  padding-block: 0.25rem 1.25rem; /* top + bottom; */
}

main > section + section {
  border-block-start: 1px solid var(--pico-muted-border-color);
}

.avatar {
  width: 256px;
  height: 256px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.about-content {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.about-photo {
  flex-shrink: 0;
}

.about-text {
  flex: 1;
  min-width: 0;
}

.about-text p {
  margin-block: 0;
  white-space: pre-line;
}

@media (max-width: 575px) {
  .about-content {
    flex-direction: column;
    align-items: center; /* center avatar on phone */
  }

  .about-text {
    width: 100%; /* keep bio full-width / left-aligned */
  }
}

.experience-list {
  list-style: none;
  padding-inline-start: 0;
  display: grid;
  gap: 1rem;
}

.experience-list article header h3 {
  margin-block-end: 0.25rem;
  font-size: 1.1rem;
}

.experience-list article header p {
  margin-block: 0 0.5rem;
  color: var(--pico-muted-color);
  font-size: 0.9rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--portfolio-card-min), 1fr));
  gap: 1.5rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.project-card-title {
  min-height: var(--project-title-min);
  display: flex;
  align-items: flex-start;
  margin-block-end: 0.5rem;
}

.project-card-title h3 {
  font-size: 1.05rem;
  line-height: 1.25;
  margin: 0;
}

.project-card-description {
  min-height: var(--project-desc-min);
  margin-block: 0 0.5rem;
  line-height: 1.65;
}

.project-card-tech {
  min-height: var(--project-tech-min);
  margin-block: 0 0.5rem;
  color: var(--pico-muted-color);
  font-size: 0.85rem;
  line-height: 1.65;
}

.project-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--pico-border-radius);
  margin-block-end: 1rem;
}

.project-links {
  margin-block-start: auto;
  padding-block-start: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.project-link-note {
  color: var(--pico-muted-color);
  font-size: 0.9rem;
}

.socials {
  list-style: none;
  padding-inline-start: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
}

.social-icon {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

footer {
  text-align: center;
  padding-block: 2rem;
  color: var(--pico-muted-color);
}

/* Theme toggle: fixed top-right, sun/moon icons swap based on resolved theme.
   "Resolved theme" = explicit data-theme attribute, falling back to OS preference.
   Note: Pico's classless <button> rule shadows --pico-color to be the primary
   inverse (white), so we use --pico-h1-color for the icon - it's not shadowed
   and tracks the theme. */
.theme-toggle {
  position: fixed;
  top: 1rem;
  inset-inline-end: 1rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 50%;
  background: var(--pico-card-background-color);
  color: var(--pico-h1-color);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--pico-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
}

.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media print {
  .theme-toggle { display: none; }
}
