/* Page-only viewport constraint. Shared banner, navigation and footer retain their styles. */
html, body { height: 100%; overflow: hidden; }
.materials-main { height: var(--materials-height, calc(100dvh - 180px)); min-width: 0; display: flex; flex-direction: column; }
.materials-heading { text-align: center; flex-shrink: 0; margin: 4px 0 8px; }
.materials-heading h1 { display: inline-block; font-size: 1.05rem; font-weight: 700; margin: 2px auto 6px; padding: 2px 14px; color: #1e4620; background: rgba(46,125,50,.15); border: 1px solid rgba(46,125,50,.3); border-radius: 30px; backdrop-filter: blur(5px); }
.materials-panel { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; width: 100%; max-width: 800px; margin: 0 auto 10px; padding: 12px; background: #fff; border-radius: 15px; border: 1px solid rgba(0,0,0,.07); box-shadow: 0 10px 25px rgba(0,0,0,.05), 0 3px 10px rgba(0,0,0,.03); }
.library-intro { text-align: center; flex-shrink: 0; }
.library-intro h2 { font-size: 1.3rem; font-weight: 600; color: #2c3e50; margin: 0 0 3px; }
.library-intro p { font-size: .82rem; color: #666; margin: 0 0 14px; }
.resource-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: repeat(2,auto); gap: 10px; flex: 0 1 auto; min-height: 0; }
.resource-card { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px; background: #fcfefb; border: 1px solid #a9c5aa; border-radius: 12px; box-shadow: 0 2px 5px rgba(30,70,32,.07); transition: border-color .2s, box-shadow .2s; }
.resource-card:hover { border-color: #2e7d32; box-shadow: 0 4px 12px rgba(30,70,32,.12); }
.resource-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.resource-icon { display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; background: #eaf5eb; color: #2e7d32; font-size: 22px; }
.resource-type { font-size: 9px; letter-spacing: .5px; color: #707b73; font-weight: 600; }
.resource-card h2 { font-size: 1rem; line-height: 1.35; color: #333; font-weight: 600; margin: 0 0 8px; }
.resource-card p { font-size: .78rem; line-height: 1.4; color: #666; margin: 0 0 10px; }
.resource-card h3 { font-size: .75rem; line-height: 1.4; font-weight: 500; color: #444; margin: 0 0 6px; }
.resource-card > .resource-actions, .resource-action { margin-top: auto; }
.resource-actions { display: flex; gap: 6px; }
.resource-actions > * { flex: 1; }
.resource-actions button, .resource-actions a, .resource-action { display: flex; align-items: center; justify-content: center; min-height: 32px; padding: 5px 8px; border-radius: 6px; border: 1px solid #d0e7d2; background: #eaf5eb; color: #1e4620; text-decoration: none; font-size: .72rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.resource-actions a, .resource-action.primary { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.resource-actions button:hover { background: #d0e7d2; }
.resource-actions a:hover, .resource-action.primary:hover { background: #1e4620; color: #fff; }
.resource-action.primary { gap: 12px; }
.resource-item { margin-top: 4px; padding-top: 0; }
.resource-item + .resource-item { border-top: 1px solid #d0dfd0; margin-top: 8px; padding-top: 8px; }
.edition-badge { display: inline-block; padding: 1px 5px; margin-left: 4px; border-radius: 4px; background: #eaf5eb; color: #2e7d32; font-size: 9px; }
.publications-card { grid-column: span 2; }
.library-note { flex-shrink: 0; padding-top: 10px; color: #777; font-size: .68rem; text-align: center; }
.resource-pager { display: none; }
.materials-main :where(a,button):focus-visible, #pdfPreview :where(a,button):focus-visible { outline: 3px solid #76a978; outline-offset: 2px; }
.materials-main.is-compact .resource-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
.materials-main.is-compact .resource-card { display: none; }
.materials-main.is-compact .resource-card.is-current { display: flex; grid-column: auto; }
.materials-main.is-compact .resource-pager { display: flex; justify-content: center; align-items: center; gap: 22px; padding-top: 10px; padding-bottom: 4px; }
.resource-pager #resourcePage { font-size: 14px; font-weight: 800; color: #1b5e20; min-width: 56px; text-align: center; padding: 4px 12px; background: rgba(46, 125, 50, 0.12); border-radius: 20px; border: 1.5px solid rgba(46, 125, 50, 0.25); letter-spacing: 0.5px; }
.resource-pager button { width: 46px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid #2e7d32; border-radius: 10px; background: #eaf5eb; color: #1b5e20; cursor: pointer; box-shadow: 0 3px 8px rgba(46, 125, 50, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.8); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.resource-pager button svg { width: 22px; height: 22px; stroke: #1b5e20; stroke-width: 3.5; transition: transform 0.2s ease, stroke 0.2s ease; }
.resource-pager button:hover:not(:disabled) { background: #2e7d32; border-color: #1b5e20; color: #ffffff; box-shadow: 0 6px 14px rgba(46, 125, 50, 0.35); transform: translateY(-2px); }
.resource-pager button:hover:not(:disabled) svg { stroke: #ffffff; transform: scale(1.15); }
.resource-pager button:active:not(:disabled) { transform: translateY(0) scale(0.95); background: #1b5e20; box-shadow: 0 2px 4px rgba(27, 94, 32, 0.25); }
.resource-pager button:focus-visible { outline: 3px solid #76ff03; outline-offset: 3px; border-color: #1b5e20; box-shadow: 0 0 0 5px rgba(46, 125, 50, 0.35); }
.resource-pager button:disabled { opacity: 0.3; background: #f0f4f0; border-color: #c4d4c6; color: #889988; cursor: not-allowed; box-shadow: none; transform: none; }
.resource-pager button:disabled svg { stroke: #889988; transform: none; }
.materials-main.is-short .library-intro, .materials-main.is-short .library-note, .materials-main.is-short .resource-top, .materials-main.is-short .resource-card > p { display: none; }
.materials-main.is-short .materials-panel { padding: 10px; }
.materials-main.is-short .resource-card { padding: 8px; }
.materials-main.is-short .resource-card h2 { font-size: .9rem; margin-bottom: 4px; }
#pdfPreview { width: min(1100px,96vw); height: 94vh; height: 94dvh; max-height: 94dvh; padding: 0; border: 1px solid #d0e7d2; border-radius: 14px; overflow: hidden; color: #1e4620; }
#pdfPreview[open] { display: flex; flex-direction: column; }
#pdfPreview::backdrop { background: rgba(0,0,0,.65); }
.preview-header, .preview-footer { display: flex; align-items: center; gap: 14px; padding: 12px 18px; flex-shrink: 0; }
.preview-header h2 { font-size: 16px; margin: 0; flex: 1; }
.preview-header button { border: none; background: #eaf5eb; border-radius: 6px; width: 36px; height: 36px; font-size: 24px; }
#pdfIframe { flex: 1; min-height: 0; width: 100%; border: 0; background: #f8fafc; }
.preview-footer { font-size: 12px; }
.preview-footer span { flex: 1; }
.preview-footer a { color: #2e7d32; text-decoration: underline; white-space: nowrap; }
/* Tablet & Mobile devices: enable vertical scrollbar when needed */
@media (max-width: 1024px) {
  html, body {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* Elegant themed vertical scrollbar */
  body::-webkit-scrollbar,
  html::-webkit-scrollbar {
    width: 6px;
  }
  body::-webkit-scrollbar-track,
  html::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
  }
  body::-webkit-scrollbar-thumb,
  html::-webkit-scrollbar-thumb {
    background: rgba(46, 125, 50, 0.5);
    border-radius: 4px;
  }
  body::-webkit-scrollbar-thumb:hover,
  html::-webkit-scrollbar-thumb:hover {
    background: rgba(30, 70, 32, 0.8);
  }

  .materials-layout {
    padding-bottom: 90px !important;
  }

  @media (max-width: 767px) {
    .materials-layout {
      padding-bottom: 160px !important;
    }
  }

  .materials-main {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  .materials-panel {
    padding: 12px;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  .preview-footer { flex-wrap: wrap; gap: 8px; }
  .preview-footer span { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .resource-card { transition: none; } }

/* Increase right main content font size when device is wider than 1900px */
@media only screen and (min-width: 1900px) {
  .materials-heading h1 {
    font-size: 1.35rem;
    padding: 4px 22px;
  }

  .materials-panel {
    max-width: 980px;
    padding: 20px;
    margin-bottom: 18px;
  }

  .library-intro h2 {
    font-size: 1.65rem;
  }

  .library-intro p {
    font-size: 1.05rem;
  }

  .resource-grid {
    gap: 14px;
  }

  .resource-card {
    padding: 16px;
  }

  .resource-top {
    gap: 10px;
    margin-bottom: 10px;
  }

  .resource-icon {
    width: 38px;
    height: 38px;
    font-size: 26px;
  }

  .resource-type {
    font-size: 11px;
    letter-spacing: 0.6px;
  }

  .resource-card h2 {
    font-size: 1.25rem;
    line-height: 1.35;
    margin-bottom: 10px;
  }

  .resource-card p {
    font-size: 0.98rem;
    line-height: 1.45;
    margin-bottom: 12px;
  }

  .resource-card h3 {
    font-size: 0.94rem;
    line-height: 1.45;
    margin-bottom: 8px;
  }

  .resource-actions {
    gap: 8px;
  }

  .resource-actions button,
  .resource-actions a,
  .resource-action {
    font-size: 0.88rem;
    min-height: 38px;
    padding: 7px 14px;
    border-radius: 8px;
  }

  .edition-badge {
    font-size: 11px;
    padding: 2px 7px;
  }

  .library-note {
    font-size: 0.88rem;
    padding-top: 14px;
  }

  .materials-main.is-compact .resource-pager {
    font-size: 15px;
    padding-top: 12px;
  }
}
