/* =================================== */
/* 1. GLOBAL STYLES & VARIABLES      */
/* =================================== */

:root {
  --clr-primary-1: #cba10a;
  --clr-primary-2: #f5c105;
  --clr-secondary-1: #9D9167;

  /* Text & Background Colors */
  --clr-text-primary: #000000;
  --clr-text-secondary-1: #cba10a;
  --clr-text-secondary-2: #fff;

  /* Font Families */
  --ff-primary: "Roboto", sans-serif;
  --ff-secondary: "Raleway", sans-serif;

  /* Line-height */
  --lh-tight: 1rem;
  --lh-snug: 1.1rem;
  --lh-normal: 1.4rem;
  --lh-relaxed: 1.7rem;
  --lh-loose: 2rem;

  /* Font sizes */
  --fs-100: 0.7rem;
  --fs-200: 0.9rem;
  --fs-300: 1rem;
  --fs-400: 1.3rem;
  --fs-600: 1.5rem;
  --fs-900: 2.2rem;
  --fs-1000: 2.5rem;
  --fs-1100: 5rem;
  --fs-1200: 6rem;

  /* Reusable overlay color */
  --overlay-dark: rgba(55, 55, 55, 0.323);
}

/* Universal selector targets all elements. */
* {
  margin: 0; /* Removes default browser margins for a clean slate. */
  box-sizing: border-box; /* Changes the box model so padding and border are included in the element's total width and height. */
}

body {
  height: 100%;
  font-family: var(--ff-secondary);
}

html {
  scroll-behavior: smooth;
}

/* =================================== */
/* 2. BASE COMPONENT STYLES          */
/* =================================== */

.layout-container {
  display: grid;
  /* Creates a 3-column grid: a flexible margin on each side (1fr) and a central content column. */
  /* The central column is responsive: it takes up the full width minus 4rem of padding, but won't exceed 1280px. */
  grid-template-columns: 1fr min(1280px, calc(100% - 4rem)) 1fr;
}

header {
  grid-column: 1/-1; /* Spans all three columns of the layout grid. */
  background-image: url(images/camping.jpg);
  background-size: cover; /* The image covers the entire header area. */
  height: 60vh; /* Takes up 60% of the viewport height. */
  background-position: center;
  position: relative; 
  display: flex; 
  flex-direction: column;
  justify-content: space-around; 
  padding-left: 7rem;
}

header h1 {
  color: var(--clr-text-secondary-2);
  font-size: var(--fs-1200);
  font-family: var(--ff-primary);
  font-optical-sizing: auto;
  font-weight: 700;
  font-style: normal;
}

header h3 {
  color: var(--clr-primary-2);
  font-family: var(--ff-secondary);
  font-size: var(--fs-600);
}

.header-text {
  margin-top: 3.5rem;
}

.nav-links ul {
  display: flex; 
  justify-content: end; 
  gap: 3rem;
  margin-bottom: 3rem;
  margin-right: 2rem;
  list-style-type: none; 
}

.nav-links a {
  color: var(--clr-text-primary);
  text-decoration: none;
  display: inline-block;
  transition: transform 0.3s ease, box-shadow 0.4s ease;
  font-size: var(--fs-400);
}

/* Subtle hover effect for navigation links. */
.nav-links a:hover {
  transform: translateY(-4px); 
}

/* --- Mobile Navigation & Hamburger Menu --- */

/* When the mobile menu is active, it slides in from the right. */
.nav-menu.active{
  right: 0;
}
/* Styles for the hamburger menu icon when it's active (transformed into an "X"). */
.ham-menu.active .bar:nth-child(2) {
    opacity: 0; /* Middle bar fades out. */
}
.ham-menu.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg); /* Top bar moves down and rotates. */
}
.ham-menu.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg); /* Bottom bar moves up and rotates. */
}

/* The hamburger menu is hidden on desktop by default. */
.ham-menu{
  display: none;
  cursor: pointer;
}

.ham-menu.active .bar{
  width: 30px;
}

/* Individual bars of the hamburger icon. */
.bar{
  display: block;
  width: 2.2rem;
  height: 3px;
  margin: 0.313rem auto;
  background-color: var(--clr-text-primary);
  transition: all 0.3s ease-in-out;
}

/* --- Main Content Sections --- */

/* This container that holds the main page content and sits in the central grid column. */
.container {
  grid-column: 2;
}

.text-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  padding: 4rem;
}

.text-container h3 {
  color: var(--clr-primary-2);
  font-size: var(--fs-600);
}

.text-container h2{
  padding-bottom: 1rem;
  font-size: var(--fs-900);
}

.text-container p {
  line-height: var(--lh-relaxed);
  font-size: var(--fs-400);
}

.mid-content {
  display: grid;
  /* Creates a responsive grid that automatically fits as many columns as possible. */
  /* Each column will be at least 250px wide and will share extra space equally (1fr). */
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.card1 {
  background-image: url('images/jonny-gios-6kHkMDEaqVw-unsplash.jpg');
}
.card2 {
  background-image: url(images/matthew-smith-Rfflri94rs8-unsplash.jpg);
}
.card3 {
  background-image: url(images/annie-spratt-AAJOt76pQtY-unsplash.jpg);
}

.card1,
.card2,
.card3 {
  display: flex;
  align-items: center; 
  aspect-ratio: 1 / 1; /* Makes the cards perfect squares. */
  background-size: cover;
  position: relative; /* Required for positioning the ::before pseudo-element. */
  box-shadow: 5px 5px var(--clr-text-secondary-2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card1 h2,
.card2 h2,
.card3 h2 {
  padding-bottom: 1rem;
  position: relative;
  z-index: 2; /* Ensures the text is above the overlay. */
  color: var(--clr-text-secondary-2);
}

/* Creates a dark overlay on each card to make the white text readable. */
.card1::before,
.card2::before,
.card3::before {
  content: ''; /* Pseudo-elements require a content property. */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1; /* Sits below the text (z-index: 2) but above the background image. */
  background-color: var(--overlay-dark);
}

/* Hover effect for the cards. */
.card1:hover, 
.card2:hover,
.card3:hover {
  transform: translateY(-4px); 
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.664);
}

/* Container for the text inside the cards. */
.card-text {
  color: var(--clr-text-secondary-2);
  padding-left: 1.8rem;
  position: relative;
  z-index: 2; /* Keeps text above the overlay. */
  line-height: var(--lh-snug);
  font-size: var(--fs-300);
  cursor: pointer;
}

.card-text h2:hover {
  text-decoration: underline;
}

.card-text p{
  line-height: var(--lh-normal);
  font-size: 1.9rem;
}

/* Styling for the fourth card, which contains the form. */
.card4 {
  background-image: url(images/tino-rischawy-kJ1Ndy-Q3Fw-unsplash.jpg);
  background-size: cover;
  background-position: center;
  aspect-ratio: 16 / 9; /* Widescreen aspect ratio. */
  position: relative;
  display: flex;
  justify-content: center; 
  align-items: center; 
  padding: 2rem;
  overflow: hidden;
}

/* Dark overlay for the form card. */
.card4::before {
  content: ''; /* Empty box - virtual element, required for a ::before or ::after pseudo-elemen */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--overlay-dark);
}

/* The form itself. */
.card4 form {
  position: relative;
  z-index: 2; /* Places the form above the overlay. */
  background-color: var(--clr-secondary-1);
  padding: 2rem;
  border-radius: 0.5rem; 
  max-width: 25rem; 
  width: 100%;
}

form h3 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: var(--fs-600);
}

input {
  box-sizing: border-box;
  padding: 0.75rem 1.25rem;
  margin: 0.5rem 0;
  width: 100%;
  border: 0;
}

input:focus {
  background-color: var(--clr-primary-2);
}

button {
  width: 100%;
  background-color: var(--clr-primary-2);
  color: var(--clr-text-primary);
  padding: 0.875rem 1.25rem;
  margin: 0.5rem 0;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-family: var(--ff-secondary);
  font-size: medium;
}

.text-content {
  padding: 4rem;
  text-align: center;
}

footer {
  margin-top: 2rem;
  grid-column: 1/-1; /* Spans the full width of the layout grid. */
}

footer p {
  padding: 1rem;
  text-align: center;
}

/* =================================== */
/* 3. MEDIA QUERIES                  */
/* =================================== */

/* --- LARGE DESKTOPS & UP (1440px and wider) --- */
@media (min-width: 1440px) {

  /* This rule I don't really need with the main layout-container but can act as a fallback if it fails/ */
 .container {
    max-width: 1280px; 
  }
}

/* --- DESKTOPS & UP (938px and wider) --- */
@media (min-width: 938px) {

  .mid-content {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Shows the standard desktop navigation. */
  .nav-links {
    display: block; 
  }

  .nav-links ul {
    display: flex; 
  }

  /* Hides the mobile hamburger menu. */
  .ham-menu {
    display: none; 
  }

  .card-text p{
    line-height: var(--lh-tight);
    font-size: var(--fs-100);
  }
}

/* --- TABLETS & SMALLER (938px and narrower) --- */
@media (max-width: 938px) {

  /* Centers the header content on smaller screens. */
  header{
    padding-left: 2rem;
    padding-right: 2rem;
    text-align: center;
  }

  .container{
    grid-column: 1/-1;
  }

  header h1 {
    font-size: var(--fs-1100);
  }

  .header-text{
    margin-top: 4rem;
  }

  /* Hides the desktop navigation links, preparing for the mobile menu. */
  .nav-links {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    transition-delay: 0.3s;
  }
  
  .nav-menu .nav-links ul{
    display: flex;
    flex-direction: column; 
    gap: 2rem;
    list-style-type: none;
  }

  /* Displays the hamburger menu icon. */
  .ham-menu {
    display: block;
    position: fixed; /* Keeps it fixed in the viewport during scroll. */
    top: 2rem;
    right: 2rem;
    z-index: 101; /* Ensures it's above the slide-out menu panel. */
  }

  /* The slide-out menu panel. Positioned off-screen to the right. */
  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%; /* Hides the menu off-screen. */
    width: 50%;
    height: 100vh;
    background-color: var(--clr-text-secondary-2);
    z-index: 100;
    transition: right 0.4s ease-in-out;
    display: flex;
    align-items: center; 
  }
  
  /* When the menu is active, this makes the navigation links visible. */
  .nav-menu.active .nav-links{
    display: block;
    opacity: 1;
    visibility: visible;
    transition-delay: 0.3s;
  }

  .text-container p{
    font-size: 1.7rem;
    line-height: var(--lh-loose);
  }

  /* Stacks the cards into a single column. */
  .mid-content{
    grid-template-columns: 1fr;
    justify-items: center; 
  }

  /* Adjusts card size for the single-column layout. */
  .card1,
  .card2,
  .card3 {
    width: 80%;
    max-width: 28.125rem; 
  }

  /* Increases padding inside the larger, single-column cards. */
  .card-text{
    padding: 3rem;
  }

  .card-text h2{
    font-size: var(--fs-1000);
  }

  .card-text p{
    font-size: var(--fs-300);
    line-height: var(--lh-relaxed);
  }
}

/* --- MOBILE DEVICES (768px and narrower) --- */
@media (max-width: 768px) {
  
  header h1{
    font-size: var(--fs-1000);
  }

  .header-text{
    margin-top: 7rem;
  }

  .text-container{
    padding: 1rem;
    margin-top: 1rem;
  }

  .text-container p{
    line-height: var(--lh-relaxed);
    margin: 1rem 0 1rem 0;
    font-size: 1.4rem;
  }

  .text-content{
    padding: 2rem;
  }

  .card-text{
    padding: 1rem;
  }

  .card-text h2{
    font-size: var(--fs-600);
  }

  .card-text p{
    font-size: var(--fs-200);
  }

  /* On small screens, the form card loses its background image for simplicity. */
  .card4{
    aspect-ratio: auto;
    background: none;
    padding: 0;
  }

  .card4::before{
    display: none;
  }

  /* The form takes up more of the screen width. */
  .card4 form{
    width: 90%;
    max-width: none;
  }
}