/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ── */
:root {
  --bg:           #f8f6f2; /* Slightly warmer bg */
  --surface:      #ffffff;
  --border:       #e8e2d9;
  --accent:       #c8472a;
  --accent-hover: #b03a20;
  --accent-soft:  #fceee8;
  --text:         #1a1714;
  --muted:        #8a8276;
  --shadow:       0 2px 8px rgba(0,0,0,0.05);
  --shadow-hover: 0 12px 32px rgba(200, 71, 42, 0.12);
  --radius:       12px;
  --header-h:     72px;
}

/* ── Base ── */
body {
  font-family: 'Geologica', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ── Top Logo ── */
.top-logo-container {
  padding: 48px 24px 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.top-logo {
  display: block;
  margin: 0 auto;
}

.top-logo img {
  height: 100px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* ── Banners ── */
.home-banners {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 24px;
  margin-bottom: 64px;
  width: 100%;
}

.home-banner-wrapper {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.06);
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  background: white;
  display: flex;
  padding: 4px; /* Safe area to prevent corner clipping */
}

.home-banner {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.home-banner-wrapper:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(var(--surface-rgb), 0.85); /* If we had RGB variables */
}

/* Fallback for backdrop-filter */
header { background: var(--surface); }

.header-inner {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo img {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.btn-icon {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Main ── */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.hero {
  text-align: center;
  margin-bottom: 56px;
}

h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Section ── */
.section { margin-bottom: 64px; }

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 6px 14px;
  border-radius: 6px;
  margin-bottom: 28px;
}

.section-label::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 32px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  position: relative;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--border);
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.card:hover .card-image img {
  transform: scale(1.05);
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover .card-overlay {
  opacity: 1;
}

.btn-view {
  background: var(--accent);
  color: white;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.card:hover .btn-view {
  transform: translateY(0);
}

.card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tag {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Native Dialog Modal ── */
.modal-dialog {
  padding: 0;
  border: none;
  background: transparent;
  width: 100%;
  max-width: 960px;
  max-height: 90vh;
  margin: auto;
  border-radius: 16px;
  box-shadow: 0 32px 128px rgba(0,0,0,0.5);
  overflow: hidden;
}

.modal-dialog::backdrop {
  background: rgba(18, 16, 14, 0.85);
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--surface);
  width: 100%;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-outline {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg);
  border-color: var(--muted);
}

.btn-close {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  font-size: 1.2rem;
}

.btn-close:hover {
  background: var(--accent-hover);
  color: white;
  border-color: var(--accent-hover);
}

.modal-body {
  flex: 1;
  position: relative;
  background: #525659; /* Standard PDF viewer bg color */
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.iframe-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 1;
  transition: opacity 0.3s ease;
}

.iframe-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Footer ── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 64px 24px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.footer-logo {
  display: block;
  margin: 0 auto 32px;
}

.footer-logo img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
  list-style: none;
}

.footer-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-nav a:hover { color: var(--accent); }

.footer-social {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 32px;
}

.footer-social a {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s ease;
}

.footer-social a:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-3px);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .home-banners { flex-direction: column; gap: 16px; }
  main { padding: 0 20px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; }
  .home-banner-wrapper { width: 100%; height: auto; }
}

@media (max-width: 480px) {
  .header-inner { padding: 0 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .card-body { padding: 12px; }
  .card-title { font-size: 0.9rem; -webkit-line-clamp: 2; line-clamp: 2; }
  .modal-dialog { width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal-content { height: 100vh; }
  .home-banner { height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
