/* ===========================================================================
   Iker García-Ferrero — personal site
   Refined-modern design system with light/dark theming.
   =========================================================================== */

/* ---- Design tokens --------------------------------------------------------- */
:root {
  --brand-1: #0e6f83;
  --brand-2: #0b3d91;

  --bg: #f5f8fb;
  --bg-elev: #ffffff;
  --text: #1f2733;
  --text-muted: #5c6b7a;
  --heading: #0e3a52;
  --border: #e5ebf1;
  --link: #0b72d9;
  --link-hover: #0a5cb0;
  --chip-bg: rgba(14, 111, 131, 0.08);
  --code-bg: #eef2f8;
  --code-text: #334155;

  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 26px rgba(15, 23, 42, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 64rem;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --brand-1: #12a0bb;
  --brand-2: #3f6fd1;

  --bg: #0d1117;
  --bg-elev: #161b22;
  --text: #e6edf3;
  --text-muted: #9aa7b4;
  --heading: #cfe8f0;
  --border: #242c38;
  --link: #6cb4ff;
  --link-hover: #93c8ff;
  --chip-bg: rgba(56, 189, 214, 0.12);
  --code-bg: #1b222c;
  --code-text: #c9d4e0;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.55);
}

/* ---- Base ------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

img {
  max-width: 100%;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--bg-elev);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

/* ---- Header ---------------------------------------------------------------- */
.page-header {
  position: relative;
  color: #fff;
  background-image: linear-gradient(135deg, rgba(14, 111, 131, 0.92), rgba(11, 61, 145, 0.86)),
    var(--banner);
  background-size: cover;
  background-position: center;
  border-bottom-left-radius: 22px;
  border-bottom-right-radius: 22px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Pointer-reactive highlight (desktop) */
.page-header::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(
    420px circle at var(--mx, 50%) var(--my, 0%),
    rgba(255, 255, 255, 0.18),
    transparent 60%
  );
}
.page-header.is-interactive::after {
  opacity: 1;
}

.header-inner {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.75rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

.brand {
  color: #fff;
  text-decoration: none;
}
.brand:hover {
  text-decoration: none;
}

.project-name {
  display: inline-block;
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.22);
}

/* ---- Nav ------------------------------------------------------------------- */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.95rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.nav-link:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}
.nav-link.is-active {
  background: #fff;
  color: var(--brand-2);
  border-color: #fff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-left: 0.25rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background-color 0.18s ease, transform 0.18s ease;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}
.theme-toggle .icon-sun {
  display: none;
}
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ---- Main content ---------------------------------------------------------- */
.main-content {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 2rem 1rem;
  word-wrap: break-word;
}
.main-content > :first-child {
  margin-top: 0;
}

.main-content h1,
.main-content h2,
.main-content h3,
.main-content h4 {
  color: var(--heading);
  font-weight: 700;
  line-height: 1.2;
  margin: 2.25rem 0 1rem;
  letter-spacing: -0.01em;
}
.main-content h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  margin-top: 0.5rem;
}
.main-content h2 {
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  scroll-margin-top: 1.5rem;
}
.main-content p {
  margin: 0 0 1em;
}

.main-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  color: var(--code-text);
  background: var(--code-bg);
}
.main-content hr {
  height: 1px;
  border: 0;
  background: var(--border);
  margin: 2rem 0;
}

/* Limit prose line length for readability */
.prose {
  max-width: 46rem;
}

/* ---- Grid + cards ---------------------------------------------------------- */
.grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.card {
  display: flex;
  gap: 1rem;
  padding: 1.15rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  height: 100%;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--brand-1) 35%, var(--border));
}

.card-vertical {
  flex-direction: column;
  gap: 0.5rem;
}

.card-img {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 6px;
}
.card-img.wide {
  width: 100%;
  height: 150px;
  flex: none;
  object-fit: cover;
  margin-bottom: 0.35rem;
}

.card-content {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.card-content p {
  margin: 0 0 0.5rem;
}
.card-content ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}
.card-content li {
  margin-bottom: 0.3rem;
}

.card-title {
  margin: 0 0 0.3rem;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--heading);
}
.card-title a {
  color: inherit;
}

.meta {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 0.35rem;
}

.clamp-2,
.clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-2 {
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.clamp-3 {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

ins {
  text-decoration: none;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--brand-1);
}

/* Pill links inside cards (Paper · Code · Model) keep default link look */

/* ---- Section heading with a "view all" affordance -------------------------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.section-head .more-link {
  font-size: 0.95rem;
  font-weight: 600;
}

/* ---- Hero ------------------------------------------------------------------ */
.hero {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 48em) {
  .hero {
    grid-template-columns: 1.4fr 0.6fr;
  }
}

.hero-aside {
  order: -1;
}
@media (min-width: 48em) {
  .hero-aside {
    order: 0;
    position: sticky;
    top: 1rem;
  }
}

.profile-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  text-align: center;
}

.avatar {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 16px;
  border: 3px solid var(--bg-elev);
  box-shadow: var(--shadow-md);
}

.profile-role {
  margin: 0.9rem 0 0.2rem;
  font-weight: 700;
  color: var(--heading);
}
.profile-meta {
  margin: 0.15rem 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 1rem;
}
.badge-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.badge-icon:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lead {
  font-size: 1.08rem;
}

/* ---- Footer ---------------------------------------------------------------- */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.75rem 2rem;
  text-align: center;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 0.6rem;
}
.footer-links a {
  font-weight: 600;
  font-size: 0.95rem;
}
.footer-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Responsive padding ---------------------------------------------------- */
@media (max-width: 48em) {
  body {
    font-size: 16px;
  }
  .header-inner {
    padding: 1.75rem 1rem 1.25rem;
  }
  .main-content {
    padding: 1.75rem 1rem 0.5rem;
  }
  .footer-inner {
    padding: 1.5rem 1rem;
  }
}

/* ---- Motion preferences ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation: none !important;
    transition: none !important;
  }
}
