/* ============================================
   Portal Institucional Viandas - Styles
   ============================================ */
:root {
  --petroleo: #183746;
  --petroleo-deep: #102733;
  --verde: #496B5A;
  --verde-dark: #3d594b;
  --marfil: #F7F6F1;
  --gris: #E8ECE9;
  --grafito: #30383B;
  --blanco: #FFFFFF;
  --text: #30383B;
  --text-soft: #5a6568;
  --border: rgba(24, 55, 70, 0.10);
  --shadow: 0 8px 30px rgba(24, 55, 70, 0.06);
  --shadow-hover: 0 16px 40px rgba(24, 55, 70, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --container: 1200px;
  --transition: 240ms cubic-bezier(.2,.7,.2,1);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--marfil);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--verde); text-decoration: none; }
a:hover { color: var(--verde-dark); }
p, h1, h2, h3, h4 { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
select { font: inherit; }

.skip-link {
  position: absolute; left: -999px; top: 0; padding: .75rem 1rem;
  background: var(--petroleo); color: #fff; z-index: 1000; border-radius: 0 0 8px 8px;
}
.skip-link:focus { left: 1rem; }

.container { width: min(100% - 2.5rem, var(--container)); margin-inline: auto; }
.section { padding: 5.5rem 0; }
.section-alt { background: linear-gradient(180deg, #eef2ef 0%, var(--marfil) 100%); }
.section-head { margin-bottom: 2.5rem; max-width: 720px; }
.section-head-row { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-end; max-width: none; }
.section-head-row > div:first-child { max-width: 720px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--verde); margin-bottom: .85rem;
}
.eyebrow::before { content: ''; width: 28px; height: 2px; background: var(--verde); border-radius: 2px; }
.section h2, .hero h1 {
  font-family: 'Montserrat', sans-serif; color: var(--petroleo);
  line-height: 1.15; letter-spacing: -0.02em;
}
.section h2 { font-size: clamp(1.8rem, 3vw, 2.75rem); margin-bottom: 1rem; }
.section-description { color: var(--text-soft); font-size: 1.02rem; max-width: 62ch; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247, 246, 241, 0.92);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid rgba(24,55,70,0.06);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; min-height: 76px; padding: .75rem 0;
}
.brand { display: inline-flex; align-items: center; gap: .85rem; color: var(--petroleo); flex-shrink: 0; }
.brand:hover { color: var(--petroleo); }
.brand-mark svg { width: 44px; height: 44px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-sub { font-size: .75rem; color: var(--text-soft); letter-spacing: .01em; }
.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav a {
  padding: .6rem .9rem; font-size: .92rem; font-weight: 500; color: var(--text);
  border-radius: 8px; transition: color var(--transition), background var(--transition);
  position: relative;
}
.site-nav a:hover, .site-nav a:focus-visible { color: var(--petroleo); background: rgba(24,55,70,0.05); }
.site-nav a:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; }
.menu-toggle {
  display: none; width: 44px; height: 44px; flex-direction: column; justify-content: center; gap: 5px;
  border-radius: 10px; border: 1px solid var(--border);
}
.menu-toggle span { display: block; height: 2px; background: var(--petroleo); border-radius: 2px; transition: transform var(--transition), opacity var(--transition); }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Hero */
.hero {
  position: relative; padding: 5rem 0 5.5rem; overflow: clip;
  background: linear-gradient(135deg, var(--marfil) 0%, #eef3f0 55%, #e6ece8 100%);
}
.hero-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 60% at 80% 20%, rgba(73,107,90,0.10), transparent 70%),
    radial-gradient(ellipse 50% 50% at 10% 80%, rgba(24,55,70,0.06), transparent 70%);
}
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3.5rem; align-items: center; position: relative; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.75rem); margin-bottom: 1.25rem; max-width: 14ch; }
.hero-description { font-size: 1.08rem; color: var(--text-soft); max-width: 58ch; margin-bottom: 2rem; line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .85rem; margin-bottom: 2.5rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.4rem; border-radius: 10px; font-weight: 600; font-size: .92rem;
  transition: all var(--transition); border: 1px solid transparent; cursor: pointer;
  text-align: center; line-height: 1.2;
}
.btn:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; }
.btn-primary { background: var(--petroleo); color: #fff; }
.btn-primary:hover { background: var(--petroleo-deep); color: #fff; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(24,55,70,0.2); }
.btn-secondary { background: transparent; color: var(--petroleo); border-color: rgba(24,55,70,0.22); }
.btn-secondary:hover { background: rgba(24,55,70,0.04); border-color: rgba(24,55,70,0.35); color: var(--petroleo); }
.btn-sm { padding: .6rem 1rem; font-size: .84rem; border-radius: 8px; }
.btn-ghost { background: rgba(73,107,90,0.08); color: var(--verde-dark); }
.btn-ghost:hover { background: rgba(73,107,90,0.14); color: var(--verde-dark); }
.hero-stats { display: flex; gap: 2rem; padding-top: 1.75rem; border-top: 1px solid rgba(24,55,70,0.1); }
.stat { display: flex; flex-direction: column; }
.stat-value { font-family: 'Montserrat', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--petroleo); line-height: 1; margin-bottom: .3rem; }
.stat-label { font-size: .78rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.hero-media { position: relative; }
.hero-image-card {
  border-radius: 24px; overflow: hidden; box-shadow: 0 24px 60px rgba(24,55,70,0.14);
  background: var(--gris); border: 1px solid rgba(255,255,255,0.7);
}
.hero-image-card img { width: 100%; height: auto; aspect-ratio: 4/3; object-fit: cover; }

/* Cards base */
.card {
  background: var(--blanco); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  overflow: hidden;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: rgba(73,107,90,0.18); }

/* Posts */
.posts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.post-card { display: flex; flex-direction: column; height: 100%; }
.post-image { aspect-ratio: 16/10; background: var(--gris); overflow: hidden; }
.post-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms ease; }
.post-card:hover .post-image img { transform: scale(1.02); }
.post-body { padding: 1.5rem; display: flex; flex-direction: column; flex: 1; }
.post-meta { font-size: .78rem; font-weight: 600; color: var(--verde); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .6rem; }
.post-title { font-family: 'Montserrat', sans-serif; font-size: 1.15rem; line-height: 1.35; color: var(--petroleo); margin-bottom: .65rem; font-weight: 600; }
.post-desc { color: var(--text-soft); font-size: .94rem; line-height: 1.7; flex: 1; }
.post-link { margin-top: 1.25rem; font-weight: 600; font-size: .88rem; color: var(--verde); display: inline-flex; align-items: center; gap: .35rem; }
.post-link:hover { color: var(--verde-dark); }
.post-link svg { width: 16px; height: 16px; }

/* Gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.gallery-item {
  position: relative; border-radius: var(--radius); overflow: hidden; background: var(--gris);
  border: 1px solid var(--border); box-shadow: var(--shadow); cursor: pointer;
  padding: 0; text-align: left; aspect-ratio: 4/3;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms ease; }
.gallery-item:hover img { transform: scale(1.03); }
.gallery-item:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; }
.gallery-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 1.25rem; background: linear-gradient(to top, rgba(16,39,51,0.72) 0%, rgba(16,39,51,0.0) 55%);
  color: #fff;
}
.gallery-overlay strong { font-family: 'Montserrat', sans-serif; font-size: .95rem; font-weight: 600; line-height: 1.3; }
.gallery-overlay span { font-size: .8rem; opacity: .88; margin-top: .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gallery-zoom {
  position: absolute; top: .85rem; right: .85rem; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.92); color: var(--petroleo); display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1); opacity: 0; transform: translateY(-4px); transition: all var(--transition);
}
.gallery-item:hover .gallery-zoom, .gallery-item:focus-visible .gallery-zoom { opacity: 1; transform: translateY(0); }
.gallery-zoom svg { width: 18px; height: 18px; }

/* Documents */
.filter-wrap { display: flex; flex-direction: column; gap: .4rem; min-width: 200px; }
.filter-label { font-size: .75rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.filter-select {
  padding: .7rem 2.2rem .7rem .9rem; border-radius: 10px; border: 1px solid rgba(24,55,70,0.18);
  background: var(--blanco) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2330383B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right .75rem center;
  appearance: none; color: var(--text); font-size: .9rem; cursor: pointer;
}
.filter-select:focus { outline: 2px solid var(--verde); outline-offset: 1px; border-color: var(--verde); }
.docs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.doc-card { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; height: 100%; }
.doc-top { display: flex; gap: 1rem; align-items: flex-start; }
.doc-icon {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px;
  background: rgba(24,55,70,0.07); color: var(--petroleo); display: grid; place-items: center;
}
.doc-icon svg { width: 24px; height: 24px; }
.doc-category {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--verde-dark); background: rgba(73,107,90,0.1); padding: .25rem .55rem; border-radius: 5px; margin-bottom: .5rem;
}
.doc-name { font-family: 'Montserrat', sans-serif; font-size: 1.05rem; font-weight: 600; color: var(--petroleo); line-height: 1.35; }
.doc-desc { color: var(--text-soft); font-size: .9rem; line-height: 1.65; flex: 1; }
.doc-meta { font-size: .8rem; color: var(--text-soft); }
.doc-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: auto; padding-top: .5rem; }
.doc-actions .btn { flex: 1; min-width: 120px; }
.doc-actions .btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Links */
.links-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.link-card {
  padding: 1.5rem; display: flex; gap: 1rem; align-items: flex-start; color: var(--text);
  height: 100%;
}
.link-card:hover { color: var(--text); }
.link-icon {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px;
  background: rgba(73,107,90,0.1); color: var(--verde); display: grid; place-items: center;
  transition: all var(--transition);
}
.link-card:hover .link-icon { background: var(--verde); color: #fff; }
.link-icon svg { width: 22px; height: 22px; }
.link-name { font-family: 'Montserrat', sans-serif; font-weight: 600; color: var(--petroleo); font-size: 1rem; margin-bottom: .3rem; line-height: 1.3; }
.link-desc { font-size: .9rem; color: var(--text-soft); line-height: 1.6; }
.link-arrow { margin-left: auto; color: rgba(24,55,70,0.3); transition: all var(--transition); flex-shrink: 0; margin-top: .2rem; }
.link-card:hover .link-arrow { color: var(--verde); transform: translate(2px, -2px); }
.link-arrow svg { width: 18px; height: 18px; }

/* Empty state */
.empty-state {
  grid-column: 1 / -1; padding: 2.5rem 1.5rem; text-align: center; color: var(--text-soft);
  background: rgba(255,255,255,0.5); border: 1px dashed rgba(24,55,70,0.18); border-radius: var(--radius);
  font-size: .95rem;
}

/* Footer */
.site-footer {
  background: var(--petroleo); color: rgba(255,255,255,0.86); padding: 3rem 0;
  margin-top: 1rem;
}
.footer-inner { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-end; }
.footer-name { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1.2rem; color: #fff; margin-bottom: .5rem; }
.footer-text { max-width: 52ch; font-size: .92rem; line-height: 1.7; color: rgba(255,255,255,0.72); }
.footer-meta { text-align: right; font-size: .85rem; color: rgba(255,255,255,0.66); }
.footer-meta p + p { margin-top: .4rem; }
.footer-copy { color: rgba(255,255,255,0.5); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 500; display: none;
}
.lightbox.is-open { display: block; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(16, 39, 51, 0.92); }
.lightbox-dialog {
  position: relative; width: min(100% - 2rem, 1100px); margin: 3vh auto; height: 94vh;
  display: flex; align-items: center; justify-content: center; gap: .75rem; pointer-events: none;
}
.lightbox-dialog > * { pointer-events: auto; }
.lightbox-figure {
  margin: 0; flex: 1; max-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 0;
}
.lightbox-figure img {
  max-width: 100%; max-height: calc(94vh - 100px); width: auto; height: auto;
  border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); background: rgba(255,255,255,0.04);
}
.lightbox-caption { text-align: center; color: #fff; padding: 1rem 1rem 0; max-width: 70ch; }
.lightbox-caption strong { display: block; font-family: 'Montserrat', sans-serif; font-size: 1rem; font-weight: 600; }
.lightbox-caption span { display: block; font-size: .88rem; color: rgba(255,255,255,0.72); margin-top: .2rem; }
.lightbox-caption span:empty, .lightbox-caption strong:empty { display: none; }
.lightbox-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2);
  color: #fff; background: rgba(255,255,255,0.08); display: grid; place-items: center;
  font-size: 1.5rem; line-height: 1; transition: all var(--transition); flex-shrink: 0;
}
.lightbox-btn:hover { background: rgba(255,255,255,0.18); }
.lightbox-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lightbox-close { position: absolute; top: 0; right: 0; font-size: 1.75rem; z-index: 2; }
.lightbox-nav { font-size: 1.2rem; }

/* Noscript */
.noscript-banner {
  position: fixed; bottom: 0; left: 0; right: 0; padding: 1rem; background: #183746; color: #fff;
  text-align: center; font-size: .9rem; z-index: 999;
}
.noscript-banner code { background: rgba(255,255,255,0.15); padding: .1rem .35rem; border-radius: 4px; }

/* Responsive */
@media (max-width: 1024px) {
  .posts-grid, .docs-grid, .links-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .hero h1 { max-width: 16ch; }
}
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; top: calc(100% + 1px); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: .25rem; padding: 1rem 1.25rem 1.25rem;
    background: rgba(247,246,241,0.98); border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 30px rgba(24,55,70,0.08);
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: .75rem 1rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero { padding: 3.5rem 0 4rem; }
  .hero h1 { max-width: 18ch; }
  .hero-media { max-width: 680px; width: 100%; margin-inline: auto; }
  .section-head-row { flex-direction: column; align-items: stretch; }
  .filter-wrap { max-width: 280px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .footer-meta { text-align: left; }
}
@media (max-width: 640px) {
  .section { padding: 4rem 0; }
  .container { width: min(100% - 1.5rem, var(--container)); }
  .posts-grid, .docs-grid, .links-grid, .gallery-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: .85rem; }
  .gallery-overlay { padding: .85rem; }
  .gallery-overlay strong { font-size: .85rem; }
  .gallery-overlay span { display: none; }
  .hero-stats { gap: 1.5rem; }
  .stat-value { font-size: 1.35rem; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
  .doc-actions .btn { width: auto; flex: 1; }
  .lightbox-dialog { width: calc(100% - 1rem); margin: 1rem auto; height: calc(100vh - 2rem); gap: .25rem; }
  .lightbox-nav { width: 38px; height: 38px; font-size: 1rem; position: absolute; bottom: .5rem; }
  .lightbox-prev { left: calc(50% - 44px); }
  .lightbox-next { right: calc(50% - 44px); }
  .lightbox-figure img { max-height: calc(100vh - 170px); }
  .lightbox-close { top: .25rem; right: .25rem; }
}
@media (max-width: 400px) {
  .gallery-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media print {
  .site-header, .hero-actions, .lightbox, .menu-toggle, .filter-wrap, .gallery-zoom { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
