:root {
  --adriatic: #1A4C6E;
  --foam: #E7F0F4;
  --terracotta: #B55E3C;
  --sepia: #6B4E3D;
  --saffron: #E2A72E;
  --indigo: #313A82;
  --crimson: #8E2B2B;
  --teal: #1F6D68;
  --slate: #44525E;
  --seagreen: #2E7E6F;
  --ink: #0D1117;
  --paper: #FCFCFA;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.12);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.16);
  
  /* Theme variables */
  --bg-primary: #FCFCFA;
  --bg-secondary: white;
  --text-primary: #0D1117;
  --text-secondary: #44525E;
  --border-color: rgba(0,0,0,0.08);
  --card-bg: white;
  --header-bg: white;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --text-primary: #E7F0F4;
  --text-secondary: #8B949E;
  --border-color: rgba(255,255,255,0.1);
  --card-bg: #161B22;
  --header-bg: #161B22;
  --paper: #0D1117;
  --ink: #E7F0F4;
  --foam: #1C2128;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3 {
  font-family: 'EB Garamond', Georgia, Times, serif;
  letter-spacing: 0.2px;
  font-weight: 500;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 0.5rem;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin-bottom: 1rem;
}

a {
  color: var(--adriatic);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

button {
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

/* Layout Structure */
.wrap {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* Header - Mobile First */
header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s;
}

@media (min-width: 768px) {
  header {
    padding: 1.25rem 2rem;
  }
}

.brand {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--adriatic);
}

@media (min-width: 768px) {
  .brand {
    font-size: 1.125rem;
  }
}

nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.language-switcher {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
  max-width: 280px;
}

.language-switcher button {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--adriatic);
  background: transparent;
  color: var(--adriatic);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
}

@media (min-width: 768px) {
  .language-switcher button {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .language-switcher {
    max-width: none;
  }
  
  .language-switcher button {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* RTL Support for Arabic */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .back-button {
  direction: ltr;
  unicode-bidi: embed;
}

[dir="rtl"] .language-switcher {
  direction: ltr;
}

.language-switcher button[aria-pressed="true"] {
  background: var(--adriatic);
  color: white;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s;
}

.theme-toggle:hover {
  transform: rotate(20deg);
  background: var(--foam);
}

/* Main Content - Mobile First */
main {
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 768px) {
  main {
    padding: 2rem;
  }
}

.portals-section {
  animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-text {
  text-align: center;
  margin-bottom: 3rem;
}

.tagline {
  font-size: 1.125rem;
  color: var(--slate);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.portal-explanation {
  max-width: 800px;
  margin: 0 auto 3rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--slate);
  text-align: left;
  padding: 0 2rem;
}

@media (max-width: 768px) {
  .portal-explanation {
    padding: 0 1rem;
    font-size: 1rem;
  }
}

/* Portal Grid - Mobile First */
.portals {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .portals {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .portals {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 4rem;
  }
}

.portal {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--foam);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  min-height: 280px;
  transition: transform 0.3s, box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  .portal {
    min-height: 380px;
    border-radius: 16px;
  }
}

.portal:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.portal-media {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.portal img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.05) saturate(0.95);
  transition: transform 0.8s, filter 0.8s;
}

.portal-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.8s;
}

.portal:hover .portal-video {
  opacity: 1;
}

.portal:hover img {
  transform: scale(1.1);
  filter: contrast(1.1) saturate(1.1) blur(2px);
}

.label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%);
  color: white;
  z-index: 2;
}

.label h3 {
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.label p {
  opacity: 0.95;
  font-size: 0.95rem;
  font-style: italic;
}

/* Portal Overlay Effect */
.portal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at var(--mx, 50%) var(--my, 50%),
    rgba(255,255,255,0.15) 0%,
    rgba(255,255,255,0) 60%
  );
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

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

/* Library Introduction */
.library-intro {
  max-width: 800px;
  margin: 0 auto 3rem;
  text-align: center;
  padding: 0 2rem;
}

.library-intro h1 {
  font-size: 2.5rem;
  color: var(--adriatic);
  margin-bottom: 2rem;
  font-weight: 600;
  line-height: 1.2;
}

@media (max-width: 768px) {
  .library-intro h1 {
    font-size: 2rem;
  }
}

.intro-text {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--slate);
  margin-bottom: 1.5rem;
  text-align: left;
}

/* Library Context Main */
.library-context-main {
  margin: 3rem 0 4rem;
  padding: 2rem;
  background: linear-gradient(135deg, var(--foam) 0%, rgba(232, 213, 181, 0.3) 100%);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(26, 76, 110, 0.1);
}

.library-photo-main {
  width: 100%;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 1.5rem;
}

.library-photo-secondary {
  width: 100%;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  opacity: 0.95;
}

@media (min-width: 768px) {
  .library-context-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .library-photo-main {
    grid-column: 1;
  }
  
  .library-photo-secondary {
    grid-column: 1;
  }
  
  .library-photo-caption {
    grid-column: 1;
  }
}

.library-photo-caption {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.library-photo-caption h2 {
  color: var(--adriatic);
  font-size: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .library-photo-caption h2 {
    font-size: 1.5rem;
  }
}

.library-photo-caption p {
  color: var(--slate);
  font-size: 1.125rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.library-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Library Context - Mobile First (OLD - DEPRECATED) */
.library-context {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: background-color 0.3s;
}

@media (min-width: 768px) {
  .library-context {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: center;
    margin: 4rem 0;
    padding: 2rem;
    border-radius: 16px;
  }
}

.library-photo {
  width: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.library-info h2 {
  color: var(--crimson);
  margin-bottom: 1rem;
}

.library-info p {
  color: var(--slate);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.library-doc-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: transparent;
  color: var(--adriatic);
  border: 1px solid var(--adriatic);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
  margin-top: 0.5rem;
}

.library-doc-link:hover {
  background: var(--adriatic);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Shelf Progress */
.shelf {
  margin-top: 4rem;
  padding: 2rem;
  background: linear-gradient(135deg, var(--adriatic) 0%, var(--teal) 100%);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.shelf::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.1) 0%, transparent 60%);
  pointer-events: none;
}

[data-theme="dark"] .shelf {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--adriatic) 100%);
}

.shelf-title {
  color: white;
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .shelf-title {
    font-size: 2rem;
  }
}

.shelf-spines {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 80px;
  align-items: flex-end;
  padding: 1rem;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.spine {
  width: 32px;
  height: 76px;
  border-radius: 4px;
  box-shadow: 
    inset 0 0 0 1px rgba(255,255,255,0.3),
    0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s;
  animation: slideIn 0.5s ease-out;
  position: relative;
}

.spine::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: rgba(255,255,255,0.4);
  border-radius: 1px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.spine.glow {
  box-shadow: 
    0 0 0 3px rgba(255,255,255,0.9),
    0 0 30px currentColor,
    inset 0 0 0 1px rgba(255,255,255,0.5);
  transform: translateY(-4px) scale(1.05);
}

.spine:nth-child(4n+1) { 
  background: linear-gradient(180deg, var(--saffron) 0%, color-mix(in srgb, var(--saffron) 80%, black) 100%);
}
.spine:nth-child(4n+2) { 
  background: linear-gradient(180deg, var(--indigo) 0%, color-mix(in srgb, var(--indigo) 80%, black) 100%);
}
.spine:nth-child(4n+3) { 
  background: linear-gradient(180deg, var(--crimson) 0%, color-mix(in srgb, var(--crimson) 80%, black) 100%);
}
.spine:nth-child(4n) { 
  background: linear-gradient(180deg, var(--teal) 0%, color-mix(in srgb, var(--teal) 80%, black) 100%);
}

.spine:hover {
  transform: translateY(-8px) scale(1.1);
  box-shadow: 
    inset 0 0 0 1px rgba(255,255,255,0.5),
    0 8px 20px rgba(0,0,0,0.4);
}

/* Content Area */
.content-area {
  animation: slideIn 0.5s ease-out;
}

.content-area.hidden {
  display: none;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: white;
  border: 1px solid var(--adriatic);
  color: var(--adriatic);
  border-radius: 8px;
  margin-bottom: 2rem;
  font-weight: 500;
  transition: all 0.2s;
}

.back-button:hover {
  background: var(--adriatic);
  color: white;
}

/* Cards - Mobile First */
.cards-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 768px) {
  .cards-grid {
    gap: 1.5rem;
    margin-top: 2rem;
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s;
}

@media (min-width: 768px) {
  .card {
    padding: 1.75rem;
  }
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.card h3 {
  color: var(--adriatic);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.bullets {
  padding-left: 1.25rem;
  margin-bottom: 1.5rem;
}

.bullets li {
  margin: 0.5rem 0;
  color: var(--slate);
}

.card-action {
  margin-top: 1.5rem;
}

.preserve-button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  color: white;
  transition: all 0.2s;
}

.preserve-button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.preserve-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Author Info */
.author-info {
  position: fixed;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: var(--card-bg);
  border-radius: 8px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  opacity: 0.7;
  transition: opacity 0.3s, background-color 0.3s;
  z-index: 10;
}

@media (min-width: 768px) {
  .author-info {
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
}

.author-info:hover {
  opacity: 1;
}

/* Exhibition Context */
.exhibition-context {
  margin: 3rem 0 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, var(--terracotta) 0%, var(--saffron) 100%);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  color: white;
}

[data-theme="dark"] .exhibition-context {
  background: linear-gradient(135deg, var(--crimson) 0%, var(--terracotta) 100%);
}

/* Dark mode text visibility improvements */
[data-theme="dark"] .intro-text {
  color: var(--text-secondary);
}

[data-theme="dark"] .portal-explanation {
  color: var(--text-secondary);
}

[data-theme="dark"] .library-photo-caption p {
  color: var(--text-secondary);
}

[data-theme="dark"] .library-photo-caption h2 {
  color: var(--sand);
}

[data-theme="dark"] .hero-text h2 {
  color: var(--sand);
}

[data-theme="dark"] .tagline {
  color: var(--text-tertiary);
  opacity: 0.9;
}

[data-theme="dark"] .library-intro h1 {
  color: var(--sand);
}

[data-theme="dark"] .portal .label h3 {
  color: var(--text-primary);
}

[data-theme="dark"] .portal .label p {
  color: var(--text-secondary);
  opacity: 0.95;
}

[data-theme="dark"] .library-context-main {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(232, 213, 181, 0.1) 100%);
}

[data-theme="dark"] .library-doc-link {
  background: rgba(232, 213, 181, 0.15);
  color: var(--sand);
  border: 1px solid rgba(232, 213, 181, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .library-doc-link:hover {
  background: var(--sand);
  color: var(--bg-primary);
  border-color: var(--sand);
  box-shadow: 0 4px 12px rgba(232, 213, 181, 0.3);
}

/* Specific styles for the library links in the photo caption area */
[data-theme="dark"] .library-links .library-doc-link {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .library-links .library-doc-link:hover {
  background: rgba(232, 213, 181, 0.9);
  color: var(--bg-primary);
  border-color: var(--sand);
}

/* Card content visibility in dark mode */
[data-theme="dark"] .card {
  background: var(--bg-secondary);
  border: 1px solid rgba(232, 213, 181, 0.2);
}

[data-theme="dark"] .card h3 {
  color: var(--sand);
  font-weight: 600;
}

[data-theme="dark"] .bullets li {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
}

[data-theme="dark"] .bullets li::marker {
  color: var(--ochre);
}

[data-theme="dark"] .card-footer button {
  background: rgba(232, 213, 181, 0.15);
  color: var(--sand);
  border: 1px solid rgba(232, 213, 181, 0.3);
}

[data-theme="dark"] .card-footer button:hover {
  background: var(--sand);
  color: var(--bg-primary);
}

[data-theme="dark"] .card-footer button.preserved {
  background: rgba(46, 160, 67, 0.2);
  color: var(--green);
  border-color: var(--green);
}

/* Content area background in dark mode */
[data-theme="dark"] .content-area {
  background: var(--bg-primary);
}

[data-theme="dark"] .content-area h2 {
  color: var(--sand);
}

[data-theme="dark"] .back-button {
  background: rgba(232, 213, 181, 0.15);
  color: var(--sand);
  border: 1px solid rgba(232, 213, 181, 0.3);
}

[data-theme="dark"] .back-button:hover {
  background: var(--sand);
  color: var(--bg-primary);
}

.exhibition-info {
  width: 100%;
}

.exhibition-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.exhibition-info p {
  margin: 0.25rem 0;
  opacity: 0.95;
}

.exhibition-note {
  font-style: italic;
  margin-top: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  display: block;
}

.disclaimer-note {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.3);
  font-size: 0.85rem;
  opacity: 0.9;
  font-style: italic;
}

.social-links {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.5rem;
}

.social-links a {
  color: white;
  opacity: 0.9;
  text-decoration: none;
  font-size: 0.95rem;
  transition: opacity 0.3s ease;
}

.social-links a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Accessibility */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Focus states */
*:focus-visible {
  outline: 2px solid var(--adriatic);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .portal-video {
    display: none;
  }
}

/* Photo Metadata */
.photo-metadata {
  background: var(--card-bg);
  border-left: 4px solid var(--adriatic);
  padding: 1.25rem;
  margin: 1.5rem 0;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s;
}

.photo-metadata p {
  margin: 0.5rem 0;
  color: var(--slate);
}

.photo-metadata strong {
  color: var(--ink);
}

.info-button {
  display: inline-block;
  margin: 0.5rem 0.5rem 0 0;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid var(--adriatic);
  color: var(--adriatic);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.info-button:hover {
  background: var(--adriatic);
  color: white;
  transform: translateY(-2px);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.modal.open {
  display: block;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card-bg);
  border-radius: 16px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--foam);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1;
}

.modal-close:hover {
  background: var(--adriatic);
  color: white;
  transform: rotate(90deg);
}

.modal-body {
  padding: 2rem;
}

.modal-body h2 {
  color: var(--adriatic);
  margin-bottom: 1rem;
}

.modal-body h3 {
  color: var(--slate);
  margin: 1.5rem 0 0.75rem;
  font-size: 1.125rem;
}

.photographer-years {
  color: var(--sepia);
  font-style: italic;
  margin-bottom: 1rem;
}

.doc-links ul {
  list-style: none;
  padding: 0;
}

.doc-links li {
  margin: 0.75rem 0;
}

.doc-links a {
  color: var(--adriatic);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.doc-links a:hover {
  background: var(--foam);
  transform: translateX(4px);
}

/* Responsive Design */
@media (max-width: 768px) {
  main {
    padding: 1rem;
  }
  
  .portals {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .library-context {
    grid-template-columns: 1fr;
  }
  
  header {
    padding: 1rem;
  }
  
  .brand {
    font-size: 1rem;
  }
  
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .modal-body {
    padding: 1.5rem;
  }
}
/* Video Controls Overlay - Unified for all devices */
.video-controls-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}

.video-controls-overlay button {
  pointer-events: auto;
}

.play-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border: 3px solid rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.play-button svg {
  width: 32px;
  height: 32px;
  margin-left: 3px; /* Center the play triangle */
}

.play-button:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.play-button.hidden {
  display: none;
}

/* Loading Spinner */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
}

.loading-spinner.hidden {
  display: none;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

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

.portal.video-playing .play-button {
  display: none;
}

.video-control-bar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: rgba(0, 0, 0, 0.65);
  padding: 8px;
  border-radius: 28px;
  backdrop-filter: blur(12px);
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  width: auto;
  max-width: 280px;
}

.video-control-bar.hidden {
  display: none;
}

.portal.video-playing .video-control-bar {
  display: flex;
}

.video-control-bar button {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-control-bar button:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

.stop-button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.85) !important;
  border: 2px solid rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.stop-button:active {
  background: rgba(220, 38, 38, 1) !important;
  transform: scale(0.92);
}

.stop-button svg {
  width: 18px;
  height: 18px;
}

.details-button {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px 20px;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.details-button:active {
  background: linear-gradient(135deg, var(--sand), var(--ochre));
  transform: scale(0.98);
}

/* Desktop adjustments */
@media (min-width: 768px) {
  .play-button {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
  
  .video-control-bar {
    bottom: 60px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: auto;
    padding: 10px;
    gap: 10px;
  }
  
  .video-control-bar button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
  }
  
  .details-button {
    flex: initial;
    padding: 10px 20px;
  }
}
