/* Rubén Brito - CV website styles
   Minimalist, Santander-inspired palette (red accent, neutral grays). */

:root {
  --red: #EC0000;
  --red-dark: #B30000;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 860px;
  --radius: 6px;
}

:root[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-alt: #F7F7F7;
  --border: #E5E5E5;
  --text: #1A1A1A;
  --text-muted: #5C5C5C;
  --link: var(--red-dark);
  --red-text: var(--red-dark);
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.05), 0 1px 1px rgba(20, 20, 20, 0.03);
  --shadow-md: 0 8px 20px rgba(20, 20, 20, 0.08);
  --nav-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(20, 20, 20, 0.04);
}

:root[data-theme="dark"] {
  --bg: #16181C;
  --bg-alt: #1D2024;
  --border: #2A2D33;
  --text: #ECECEC;
  --text-muted: #9A9DA3;
  --link: #F0464C;
  --red-text: var(--link);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 24px rgba(0, 0, 0, 0.45);
  --nav-shadow: 0 1px 0 var(--border), 0 2px 10px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

::selection {
  background: var(--red);
  color: #FFFFFF;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 8px;
  z-index: 100;
  background: var(--red);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 8px;
}

/* Navigation */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  box-shadow: var(--nav-shadow);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  flex-shrink: 0;
}

.nav-brand:hover {
  text-decoration: none;
  color: var(--red);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--red);
  color: var(--red);
  transform: rotate(-8deg);
}

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

.nav-links-wrap {
  overflow-x: auto;
  position: relative;
  flex: 1;
}

.nav-links-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
}

.nav-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.nav-links a {
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--red);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--red);
  font-weight: 600;
}

/* Hero */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 56px 24px 32px;
}

.hero-content {
  display: flex;
  align-items: center;
  gap: 24px;
}

.hero-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--border), var(--shadow-md);
}

.name {
  margin: 0;
  font-size: 36px;
  font-weight: 700;
}

.subtitle {
  margin-top: 4px;
  font-size: 16px;
  color: var(--red-text);
  font-weight: 600;
}

.hero-accent {
  margin-top: 16px;
  height: 2px;
  width: 72px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--red), var(--red-dark), var(--red));
  background-size: 200% 100%;
  animation: heroShimmer 7s ease-in-out infinite;
}

@keyframes targetHighlight {
  0% { background-color: rgba(236, 0, 0, 0.08); }
  100% { background-color: transparent; }
}

section:target {
  animation: targetHighlight 2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  section:target {
    animation: none;
  }
}

@keyframes heroShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-accent {
    animation: none;
  }

  .skill-category:hover,
  .project-card:hover,
  .btn:hover,
  .theme-toggle:hover {
    transform: none;
  }
}

.contact-row {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-muted);
}

.contact-row a {
  color: var(--text-muted);
}

.contact-row a:hover {
  color: var(--red);
}

.dot {
  margin: 0 8px;
}

.cv-link {
  font-weight: 600;
}

/* Content */
.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 64px;
}

section {
  padding-top: 48px;
  scroll-margin-top: 104px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--red);
  padding-bottom: 10px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--red);
}

.section-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -12px;
  margin-bottom: 20px;
}

.lead {
  color: var(--text-muted);
  font-size: 15px;
}

.cv-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Experience */
.role-block {
  padding: 16px 0 16px 16px;
  border-left: 2px solid var(--border);
  transition: border-color 0.15s ease;
}

.role-block:hover {
  border-left-color: var(--red);
}

.role-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.company {
  font-weight: 700;
  color: var(--red-text);
}

.dot-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

.position {
  font-weight: 600;
  font-style: italic;
}

.period {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
}

.project-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-muted);
}

.project-list li::marker {
  color: var(--red-text);
}

.project-list li {
  margin-bottom: 4px;
}

.dashed-divider {
  border-top: 1px dashed var(--border);
  margin: 4px 0;
}

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: start;
  gap: 20px;
}

.skill-category {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.skill-category:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.skill-category h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--red-text);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.skill-tag {
  display: inline-block;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

/* Projects (live from GitHub) */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.project-card {
  display: block;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.project-card:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-2px);
}

.project-card-title {
  font-weight: 700;
  font-size: 1em;
  color: var(--red-text);
  margin: 0 0 6px;
}

.project-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.project-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.projects-status {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Education */
.edu-block {
  padding: 14px 0 14px 16px;
  border-left: 2px solid var(--border);
  transition: border-color 0.15s ease;
}

.edu-block:hover {
  border-left-color: var(--red);
}

.edu-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
}

.school {
  font-weight: 700;
  color: var(--red-text);
}

.edu-head .period {
  margin-left: 0;
}

.edu-sub {
  font-style: italic;
  margin-top: 2px;
}

.edu-extra {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Contact / buttons */
.contact-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--red);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--red-dark);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--red);
  color: var(--red);
  box-shadow: var(--shadow-sm);
}

/* Footer */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--red);
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--red);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.15s ease;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--red-dark);
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: opacity 0.2s ease;
    transform: none;
  }
}

@media print {
  .back-to-top {
    display: none;
  }
}

/* Print */
@media print {
  .topnav,
  .skip-link,
  .contact-buttons,
  #cv .btn,
  .hero-accent {
    display: none;
  }

  body {
    background: #FFFFFF;
    color: #1A1A1A;
  }

  a {
    color: #1A1A1A;
    text-decoration: underline;
  }

  .skill-category,
  .project-card {
    box-shadow: none;
    border: 1px solid #E5E5E5;
    break-inside: avoid;
  }

  .role-block,
  .edu-block {
    break-inside: avoid;
  }

  section {
    padding-top: 24px;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: inherit;
  }
}

/* Responsive */
@media (max-width: 560px) {
  .nav-inner {
    flex-wrap: wrap;
  }

  .nav-links-wrap {
    order: 3;
    flex-basis: 100%;
    margin-top: 10px;
  }

  .hero-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .name {
    font-size: 28px;
  }

  .period {
    margin-left: 0;
  }
}
