/* =========================================================
   HIPA — Hub Interregional de innovación en sensórica del
   movimiento y agentes inteligentes
   Stylesheet — colors are CSS variables below, sampled from
   the official HIPA logo (navy #0D3B48, coral #FF5931).
   A light theme (default) and dark theme are both defined;
   js/script.js toggles [data-theme="dark"] on <html> and
   swaps the header icon to match. Headings use Fraunces
   (serif), body text uses Inter, both loaded from Google
   Fonts in the page head with system-font fallbacks below.
   ========================================================= */

:root {
  --primary: #0D3B48;        /* brand navy, headings / nav / buttons */
  --primary-soft: #E7EEF0;   /* light tint of primary, used sparingly */
  --secondary: #3E6B76;      /* muted navy-teal, links and labels */
  --accent: #FF5931;         /* brand coral, used only for emphasis */
  --bg: #FFFFFF;             /* light theme background */
  --bg-alt: #F2F5F6;         /* slightly deeper tint for alternating sections */
  --text-dark: #16262B;
  --text-muted: #5E7075;
  --text-light: #FBFBFB;     /* text drawn on top of the (always-coral) accent */
  --border: #E1E8EA;
  --radius: 6px;
  --shadow: 0 2px 10px rgba(13, 59, 72, 0.07);
  --max-width: 1360px;
  --font-heading: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --primary: #FFFFFF;
  --primary-soft: #14434F;
  --secondary: #8FC2CC;
  --accent: #FF5931;
  --bg: #0D3B48;
  --bg-alt: #0A2E38;
  --text-dark: #E8EEF0;
  --text-muted: #9FB7BC;
  --text-light: #FBFBFB;
  --border: rgba(255, 255, 255, 0.16);
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

html, body { background: var(--bg); }
body,
header.site-header,
section,
.entity-card,
.team-card,
.news-item,
form.contact-form,
.contact-info-card,
.fact-sheet,
footer.site-footer {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);

  color: var(--text-dark);
  background: var(--bg);
  line-height: 1.65;
}

img { max-width: 100%; display: block; }

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

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
  margin-top: 0;
}

.section-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 6px;
  display: block;
}

section { padding: 60px 0; border-bottom: 1px solid var(--border); }
section:last-of-type { border-bottom: none; }
section.alt { background: var(--bg-alt); }

.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid var(--primary);
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--primary);
  background: transparent;
}
.btn:hover { text-decoration: none; background: var(--primary-soft); }
.btn-primary { background: var(--accent); color: var(--text-light); border-color: var(--accent); }
.btn-primary:hover { background: #CF5230; border-color: #CF5230; }
.btn-outline { background: transparent; }

/* ---------- Header / Nav ---------- */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
}
.brand:hover { text-decoration: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.brand-logo { height: 30px; width: auto; object-fit: contain; display: block; }
.nav-wrap { flex-wrap: nowrap; }
.nav-right { display: flex; align-items: center; gap: 16px; flex-wrap: nowrap; flex-shrink: 0; }
.theme-switch-wrap { display: flex; align-items: center; }
.theme-switch {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
}
.theme-switch-track {
  display: block;
  width: 60px;
  height: 32px;
  border-radius: 999px;
  background: #E3E6EA;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.15);
  position: relative;
  transition: background-color 0.3s ease;
}
html[data-theme="dark"] .theme-switch-track { background: #22344A; }
.theme-switch-track-icon {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
}
.theme-switch-track-icon.icon-sun { left: 8px; color: #B0B6C0; }
.theme-switch-track-icon.icon-moon { right: 8px; color: #5A6C8A; }
html[data-theme="dark"] .theme-switch-track-icon.icon-sun { color: #4A5568; }
html[data-theme="dark"] .theme-switch-track-icon.icon-moon { color: #9FB3D6; }
.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #FFC773, #FF9640);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.6);
  transition: transform 0.3s ease, background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
html[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(28px);
  background: linear-gradient(145deg, #7FA6FF, #4A72D9);
}
.thumb-icon { width: 16px; height: 16px; }
.thumb-icon-moon { display: none; }
html[data-theme="dark"] .thumb-icon-sun { display: none; }
html[data-theme="dark"] .thumb-icon-moon { display: block; }
nav.main-nav ul {
  list-style: none;
  display: flex;
  gap: 26px;
  margin: 0;
  padding: 0;
}
nav.main-nav a {
  color: var(--text-dark);
  font-weight: 500;
  font-size: 0.92rem;
}
nav.main-nav a:hover { color: var(--secondary); text-decoration: none; }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 860px) {
  nav.main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px 20px;
  }
  nav.main-nav.open { display: block; }
  nav.main-nav ul { flex-direction: column; gap: 14px; }
  .nav-toggle { display: block; }
  .nav-right { gap: 10px; }
}

/* ---------- Hero ---------- */
.hero { background: var(--bg-alt); padding: 64px 0 56px; }
.hero .container { max-width: 1180px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 40px;
  align-items: center;
}
.hero-text { max-width: 620px; order: 2; }
.hero-logo-link {
  display: block;
  justify-self: start;
  order: 1;
}
.hero-logo {
  width: 100%;
  max-width: 460px;
  height: auto;
}
.hero-logo-dark { display: none; }
html[data-theme="dark"] .hero-logo-light { display: none; }
html[data-theme="dark"] .hero-logo-dark { display: block; }
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-text { order: 1; }
  .hero-logo-link { justify-self: start; margin-top: 20px; order: 2; }
  .hero-logo { max-width: 300px; }
}
.hero h1 { font-size: 2.05rem; margin-bottom: 16px; }
.hero .tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 680px;
  margin-bottom: 18px;
}
.hero .fact-line {
  font-size: 0.92rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 22px;
}
.hero .fact-line strong { color: var(--text-dark); }

/* ---------- About / Objectives ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 44px;
  align-items: start;
}
@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
}

.fact-sheet {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 24px;
  background: var(--bg-alt);
}
.fact-sheet dt {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 18px;
}
.fact-sheet dd {
  margin: 2px 0 0;
  font-size: 0.98rem;
  color: var(--text-dark);
}
.fact-sheet dd:last-of-type,
.fact-sheet dt:last-of-type { margin-bottom: 18px; }

.objective-main {
  font-size: 1.15rem;
  color: var(--text-dark);
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin-bottom: 30px;
  max-width: 760px;
}
.objectives-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}
.objectives-list li {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.objectives-list li:last-child { border-bottom: none; }
.objectives-list .obj-index {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 28px;
}

/* ---------- Entities / Partners ---------- */
.entities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.entity-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.entity-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 56px;
  margin: 0 auto 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: #FFFFFF;
}
.entity-logo-link:hover { opacity: 0.82; }
.entity-logo {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.entity-card h4 { margin-bottom: 6px; font-size: 1rem; }
.entity-card .entity-role {
  color: var(--text-muted);
  font-size: 0.87rem;
  margin: 0;
}
.logo-note {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---------- Team ---------- */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.team-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
}
.avatar-photo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: block;
  object-fit: cover;
  object-position: center center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}
.avatar-fallback {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--accent);
}
.team-card h4 { margin-bottom: 4px; font-size: 1rem; }
.team-name-link { color: var(--primary); text-decoration: none; }
.team-name-link:hover { text-decoration: underline; }
.team-roster {
  margin-top: 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 32px 36px;
}
.roster-group h4 {
  font-size: 0.95rem;
  line-height: 1.35;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.roster-group ul { list-style: none; margin: 0; padding: 0; }
.roster-group a.team-name-link {
  text-decoration: underline dotted;
  text-decoration-color: var(--secondary);
  text-underline-offset: 3px;
}
.roster-group a.team-name-link:hover { text-decoration-style: solid; }
.roster-group li {
  font-size: 0.9rem;
  padding: 4px 0;
  color: var(--text-dark);
}
.team-role {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.team-institution {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ---------- News ---------- */
.news-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.news-date {
  color: var(--text-muted);
  font-size: 0.83rem;
  margin-bottom: 8px;
  display: block;
}
.news-placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ---------- Contact ---------- */
.contact-wrap {
  display: grid;
  grid-template-columns: 1fr;
}
@media (max-width: 860px) {
  .contact-wrap { grid-template-columns: 1fr; }
}
.contact-info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  background: var(--bg-alt);
}
.contact-info-list { list-style: none; padding: 0; margin: 16px 0 0; }
.contact-info-list li {
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--text-dark);
}
.contact-info-list .label {
  color: var(--text-muted);
  display: inline-block;
  min-width: 88px;
}

form.contact-form {
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.form-row { display: grid; gap: 6px; }
.form-row label {
  font-weight: 500;
  font-size: 0.86rem;
  color: var(--text-dark);
}
.form-row input,
.form-row textarea {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.94rem;
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--secondary);
}
.form-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-two { grid-template-columns: 1fr; } }

/* honeypot field — hidden from real users */
.hp-field { position: absolute; left: -9999px; top: -9999px; }

.form-alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 4px;
  border: 1px solid var(--border);
}
.form-alert.ok { background: #EFF7F3; color: #205C42; border-color: #CFE7DA; }
.form-alert.error, .form-alert.invalid { background: #FBF0EF; color: #8F3A2E; border-color: #ECD1CC; }

/* ---------- Footer ---------- */
footer.site-footer {
  background: var(--bg-alt);
  color: var(--text-muted);
  padding: 36px 0 22px;
  font-size: 0.86rem;
  border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 30px;
  margin-bottom: 24px;
}
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }
footer.site-footer h5 {
  color: var(--text-dark);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 10px;
}
footer.site-footer ul { list-style: none; padding: 0; margin: 0; }
footer.site-footer li { margin-bottom: 7px; }
footer.site-footer a { color: var(--text-muted); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-fecyt-logo {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

/* =========================================================
   Admin panel (contact submissions viewer)
   ========================================================= */
.admin-body {
  background: var(--bg-alt);
  font-family: var(--font-body);
}
.admin-login-box {
  max-width: 360px;
  margin: 90px auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
}
.admin-login-box form { display: grid; gap: 12px; margin-top: 16px; text-align: left; }
.admin-login-box label { font-weight: 500; font-size: 0.86rem; }
.admin-login-box input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.admin-error { color: #8F3A2E; font-size: 0.88rem; }
.admin-hint { margin-top: 16px; font-size: 0.8rem; color: var(--text-muted); }

.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 30px 24px; }
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.admin-header-actions { display: flex; gap: 10px; }
.admin-search { display: flex; gap: 10px; margin-bottom: 20px; }
.admin-news-form {
  display: grid;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 30px;
  max-width: 560px;
}
.admin-news-form h3 { margin-bottom: 4px; font-size: 1.05rem; }
.admin-news-form .form-row label {
  font-weight: 500;
  font-size: 0.86rem;
  color: var(--text-dark);
  display: block;
  margin-bottom: 4px;
}
.admin-news-form .form-row input,
.admin-news-form .form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.94rem;
}
.admin-list-title { margin-bottom: 14px; font-size: 1.05rem; }
.admin-search input {
  flex: 1;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
  vertical-align: top;
}
.admin-table th { background: var(--bg-alt); color: var(--text-dark); font-weight: 600; }
.admin-table tr.is-unread { background: #FCEEE9; }
.admin-message { max-width: 320px; }
.admin-actions a { margin-right: 10px; font-size: 0.84rem; }

/* ---------- News: optional photo (photo left, text right) ---------- */
.news-item-with-image {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 24px;
  align-items: start;
}
.news-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--radius);
}
@media (max-width: 700px) {
  .news-item-with-image { grid-template-columns: 1fr; }
}

/* Admin: photo field + thumbnails */
.form-hint { font-size: 0.8rem; color: var(--text-muted); }
.admin-thumb { display: block; width: 72px; height: 54px; object-fit: cover; border-radius: 4px; }
.admin-muted { color: var(--text-muted); font-size: 0.85rem; }

/* Admin: editing a news item */
.admin-news-form .form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-dark);
  cursor: pointer;
}
.admin-news-form .form-check input[type="checkbox"] { width: auto; padding: 0; margin: 0; }
.form-current-image { display: grid; gap: 8px; }
.form-label-text { font-weight: 500; font-size: 0.86rem; color: var(--text-dark); }
.admin-current-image {
  display: block;
  max-width: 220px;
  max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.form-buttons { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-table tr.is-editing { background: var(--primary-soft); }

/* Links written inside a news text */
.news-content a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.news-content a:hover { text-decoration-color: var(--primary); }
