/*
--------------------------------------------------------------------------
CSS Custom Properties (Variables)
--------------------------------------------------------------------------
These are like global settings for your design. Change them once,
and they update everywhere! Super handy for consistency and theming.
*/
:root {
  /* Colors */
  --color-background: #000;
  --color-text-primary: #fff;
  --color-text-secondary: #f4efe4;
  --color-text-muted: #d4d4d4;
  --color-accent: #ff6f61;
  --color-card-background: #110c0c;
  --color-card-text: #e0e0e0;
  --color-card-shadow: rgba(0, 0, 0, 0.5);
  --color-card-border-inset: rgba(255, 255, 255, 0.04);
  --color-highlight-bg: rgba(255, 255, 255, 0.1);
  --color-instagram-border: rgba(255, 255, 255, 0.3);

  /* Spacing (using rem for responsiveness) */
  --spacing-xs: 0.5rem; /* 8px */
  --spacing-sm: 1rem; /* 16px */
  --spacing-md: 1.25rem; /* 20px */
  --spacing-lg: 1.5rem; /* 24px */
  --spacing-xl: 2rem; /* 32px */
  --spacing-xxl: 3rem; /* 48px */

  /* Border Radius */
  --border-radius-sm: 0.5rem; /* 8px */
  --border-radius-md: 1rem; /* 16px */
  --border-radius-lg: 1.5rem; /* 24px */
  --border-radius-xl: 2rem; /* 32px */
}

/*
--------------------------------------------------------------------------
Base Styles
--------------------------------------------------------------------------
General styles for the body, typography, and basic elements.
*/
body {
  font-family: 'Playfair Display', system-ui, -apple-system, serif;
  background: var(--color-background);
  color: var(--color-text-primary);
  margin: 0;
  min-height: 100vh; /* Use min-height for better content flow */
  overflow-x: hidden; /* Prevent horizontal scroll */
  -webkit-text-size-adjust: 100%;
  line-height: 1.6;
  display: flex; /* Use flexbox for centering content */
  flex-direction: column;
}

/*
--------------------------------------------------------------------------
Layout
--------------------------------------------------------------------------
Styles for overall page structure and containers.
*/
.container {
  text-align: center;
  padding: var(--spacing-md); /* 20px */
  animation: fadeIn 2s ease-in-out;
  max-width: 50rem; /* 800px, using rem for responsiveness */
  margin: 0 auto;
  flex-grow: 1; /* Allow container to grow and push footer down */
}

/*
--------------------------------------------------------------------------
Components
--------------------------------------------------------------------------
Styles for specific UI elements like logos, images, cards, etc.
*/
.rlogo {
  width: 4.6875rem; /* 75px */
  height: 4.6875rem; /* 75px */
  margin: var(--spacing-md) auto; /* Add some margin for spacing */
  border-radius: 50%;
  object-fit: cover; /* Ensure image covers the area */
}

.rpict {
  width: 100%;
  height: auto;
  border-radius: var(--border-radius-md); /* 16px */
  margin-top: var(--spacing-xl); /* Add space above image */
  margin-bottom: var(--spacing-xl); /* Add space below image */
  display: block; /* Remove extra space below image */
}

h1 {
  font-size: clamp(2rem, 8vw, 3.5rem); /* 2em, 8vw, 3.5em */
  font-weight: 600;
  margin-bottom: var(--spacing-md); /* 15px */
  line-height: 1.3;
  color: var(--color-text-secondary);
}

h2 {
  font-size: clamp(1.5rem, 6vw, 2.5rem); /* Adjusted for better hierarchy */
  color: var(--color-text-secondary);
  margin-top: var(--spacing-xxl); /* More space above new sections */
  margin-bottom: var(--spacing-lg);
}

p {
  font-size: clamp(1rem, 4vw, 1.3rem); /* 1em, 4vw, 1.3em */
  line-height: 1.6;
  max-width: 37.5rem; /* 600px */
  margin: var(--spacing-xl) auto; /* 20px auto */
  padding: var(--spacing-md); /* 20px */
  background: var(--color-highlight-bg);
  border-radius: var(--border-radius-lg); /* 24px */
}

.story-section {
  text-align: left;
  margin: var(--spacing-xxl) auto; /* 30px auto */
  max-width: 37.5rem; /* 600px */
}

.story-section p {
  text-align: left;
  background: none;
  padding: var(--spacing-xs) 0; /* 5px 0 */
  margin: var(--spacing-md) 0; /* 15px 0 */
}

.highlight {
  font-size: 1.1rem; /* Using rem */
  font-style: italic;
  margin: var(--spacing-xl) 0; /* 25px 0 */
  text-align: center;
  padding: var(--spacing-md); /* Add padding for better visual separation */
  background: var(--color-highlight-bg); /* Use highlight background */
  border-radius: var(--border-radius-lg);
}

.apartment-card {
  background: var(--color-card-background);
  color: var(--color-card-text);
  max-width: 25rem; /* 400px */
  margin: var(--spacing-xl) auto; /* 20px auto */
  padding: var(--spacing-lg); /* 25px */
  border-radius: var(--border-radius-md); /* 15px */
  box-shadow: 0 0.5rem 1rem var(--color-card-shadow), /* 0 8px 16px */
    inset 0 0 0 0.0625rem var(--color-card-border-inset); /* 1px */
  position: relative;
  overflow: hidden;
  z-index: 0; /* Ensure content is above pseudo-element */
}

.apartment-card:before {
  content: '';
  pointer-events: none;
  position: absolute;
  top: -100%;
  left: -50%;
  width: 300%;
  height: 400%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(0, 0, 0, 0) 20%
  );
  animation: glow 22s infinite alternate-reverse;
  z-index: -1; /* Place behind content */
}

.apartment-card h2 {
  font-size: 2rem; /* 2em */
  color: var(--color-accent);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.125rem; /* 2px */
  margin-bottom: var(--spacing-md); /* 15px */
  position: relative;
  z-index: 1;
}

.apartment-card h3 {
  font-size: 1.3rem; /* 1.3em */
  margin: var(--spacing-xl) 0 var(--spacing-sm); /* 20px 0 10px */
  z-index: 1;
}

.apartment-card p {
  font-size: 1rem; /* 1em */
  line-height: 1.6;
  margin-bottom: var(--spacing-xl); /* 20px */
  z-index: 1;
  background: none; /* Override general p style */
  padding: 0; /* Override general p style */
}

.apartment-card ul {
  list-style: none;
  padding: 0;
  z-index: 1;
}

.apartment-card ul li {
  font-size: 0.95rem; /* 0.95em */
  margin-bottom: var(--spacing-md); /* 15px */
  padding-left: 1.5625rem; /* 25px */
  position: relative;
  color: var(--color-text-muted);
}

.apartment-card ul li:before {
  content: '✦';
  color: var(--color-accent);
  position: absolute;
  left: 0;
  font-size: 1.2rem; /* 1.2em */
  animation: pulse 2s infinite alternate;
}

.apartment-card ul li:nth-child(2):before {
  animation-delay: 0.2s;
}
.apartment-card ul li:nth-child(3):before {
  animation-delay: 0.4s;
}
.apartment-card ul li:nth-child(4):before {
  animation-delay: 0.6s;
}
.apartment-card ul li:nth-child(5):before {
  animation-delay: 0.8s;
}

.instagram-link {
  display: inline-block;
  margin-top: var(--spacing-xxl); /* 30px */
  color: var(--color-text-primary);
  text-decoration: none;
  font-size: 1.1rem; /* 1.1em */
  border: 0.0625rem solid var(--color-instagram-border); /* 1px */
  padding: 0.5rem var(--spacing-md); /* 8px 15px */
  border-radius: var(--border-radius-xl); /* 20px */
  transition: all 0.3s ease;
}

.instagram-link:hover {
  background: var(--color-highlight-bg);
  transform: translateY(-0.1875rem); /* Subtle lift on hover */
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2); /* Subtle shadow */
}

/*
--------------------------------------------------------------------------
Animations
--------------------------------------------------------------------------
Keyframe definitions for various animations.
*/
@keyframes glow {
  0% {
    transform: scale(1) translate(40%, 0);
  }
  75% {
    transform: scale(1.3) translate(-20%, -10%);
  }
  100% {
    transform: scale(2) translate(0%, -20%);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.4);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/*
--------------------------------------------------------------------------
Media Queries (Responsiveness)
--------------------------------------------------------------------------
Adjustments for different screen sizes.
*/
@media (max-width: 450px) {
  .apartment-card {
    margin: var(--spacing-sm); /* 10px */
    padding: var(--spacing-md); /* 15px */
  }
  .apartment-card h2 {
    font-size: 1.5rem; /* 1.5em */
  }
  .apartment-card h3 {
    font-size: 1.1rem; /* 1.1em */
  }
}

@media (max-width: 600px) {
  .container {
    padding: var(--spacing-sm); /* 10px */
  }
  h1 {
    font-size: clamp(1.5rem, 6vw, 2.5rem); /* 1.5em, 6vw, 2.5em */
  }
  p {
    font-size: clamp(0.9rem, 3vw, 1.1rem); /* 0.9em, 3vw, 1.1em */
    padding: var(--spacing-sm); /* 10px */
  }
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: minmax(160px, auto); /* Allow rows to adjust height */
  gap: 4px;
  grid-auto-flow: dense;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box; /* Ensure padding/margins don't break layout */
  padding: 0 8px; /* Optional: small padding for mobile */
}

@media (max-width: 600px) {
  .grid-container {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2px;
  }
}

.grid-item {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  width: 100%; /* Ensure items take full grid cell width */
  height: 100%; /* Ensure items take full grid cell height */
  transition: opacity .4s;
}

.grid-item:hover {
  opacity: .8;
  z-index: 10;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.span-h2 {
  grid-column: span 2;
}

.span-v2 {
  grid-row: span 2;
}

.span-large {
  grid-column: span 2;
  grid-row: span 2;
}

/* Basic Modal Styling (adjust as needed) */
.modal {
  display: flex; /* Changed from 'none' to 'flex' for initial state, controlled by JS class */
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  opacity: 0; /* Start hidden for animation */
  visibility: hidden; /* Hide from screen readers/interaction when closed */
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out; /* Smooth fade [6] */
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-content-wrapper {
  position: relative; /* For positioning preloader and buttons */
  width: 96%;
  max-height: 96%;
  display: flex; /* To center the image and preloader */
  justify-content: center;
  align-items: center;
}

.modal-content {
  max-width: 100%;
  max-height: 100%;
  display: block; /* Remove extra space below image */
  object-fit: contain; /* Ensure image fits without cropping [8] */
  transition: opacity 0.3s ease-in-out; /* Smooth fade for image itself */
}

/* Close Button */
.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
  z-index: 1001; /* Above modal content */
  background-color: rgba(0, 0, 0, 0.5);
  text-align: center;
  width: 48px;
  height: 48px;
  line-height: 44px;
  border-radius: 50%;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

/* Navigation Buttons */
.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  padding: 10px 15px;
  font-size: 24px;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s ease;
  z-index: 100; /* Above image, below close button */
}

.nav-button:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.prev-button {
  left: 10px;
}

.next-button {
  right: 10px;
}

/* Preloader Spinner */
.preloader {
  border: 8px solid #333;
  border-top: 8px solid #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
  position: absolute; /* Center over the image area */
  display: none; /* Hidden by default, shown by JS */
  z-index: 99; /* Below image, above modal background */
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes zoom-in {
  from {
    transform: scale(0.5);
  }
  to {
    transform: scale(1);
  }
}

.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: 100;
  cursor: pointer;
  transition: color 0.3s;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
}