/*
 * COPTICO Stylesheet (Responsive)
 * Works perfectly on iOS, iPadOS, macOS, Windows, and Android.
 */

/* Root Variables */
:root {
  --primary-color: #7a1334; /* dark red */
  --accent-color: #123c7a;  /* deep blue */
  --bg-color: #f9f6f2;      /* off-white background */
  --text-color: #2e2e2e;

  --font-header: "Montserrat", sans-serif;
  --font-body: "Cairo", sans-serif;
}

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

/* Global Styles */
html,
body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;

  /* Flex layout for sticky footer */
  display: flex;
  flex-direction: column;

  /* Safe area support for iOS */
  padding-top: env(safe-area-inset-top, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Reusable container */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #ffffff;
  padding: 2rem 0;
  text-align: center;
}

header .logo {
  width: clamp(60px, 8vw, 90px);
  height: auto;
  display: block;
  margin: 0 auto 1rem auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

header h1 {
  font-family: var(--font-header);
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

header .tagline {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 500;
  opacity: 0.9;
}

/* Intro section */
.intro {
  margin: 3rem auto;
  text-align: center;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.intro h2 {
  font-family: var(--font-header);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.intro p {
  font-size: clamp(1rem, 1.8vw, 1.1rem);
  line-height: 1.6;
  max-width: 700px;
}

/* Projects grid (default for larger screens) */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

/* Project Card */
.project-card {
  display: block;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 2rem 1rem;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  text-decoration: none;
  color: var(--primary-color);
  cursor: pointer;
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  background-color: #f5f1ec;
}

.project-card .project-icon {
  width: clamp(70px, 10vw, 100px);
  height: auto;
  object-fit: contain;
  margin: 0 auto 1rem auto;
  display: block;
}

.project-card h3 {
  font-family: var(--font-header);
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
  color: var(--primary-color);
  margin: 0;
}

/* Footer */
footer {
  margin-top: auto;
  background: var(--primary-color);
  color: #ffffff;
  text-align: center;
  padding: 1.2rem 0 env(safe-area-inset-bottom, 0);
  font-size: 0.95rem;
}

/* ---------------------------------------
   Responsive Adjustments
---------------------------------------- */

/* Medium down: slightly smaller cards to fit more columns earlier */
@media (max-width: 900px) {
  .projects {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }
  .project-card {
    padding: 1.25rem 0.8rem;
  }
  .project-card .project-icon {
    width: clamp(60px, 9vw, 84px);
  }
  .project-card h3 {
    font-size: clamp(1rem, 2vw, 1.15rem);
  }
}

/* Phones & small devices: force 4 cards per row */
@media (max-width: 640px) {
  .projects {
    grid-template-columns: repeat(4, 1fr);  /* <-- four per row */
    gap: 8px;
  }
  .project-card {
    padding: 0.6rem 0.5rem;
    border-radius: 10px;
  }
  .project-card .project-icon {
    width: 44px;          /* smaller icon */
    margin-bottom: 0.45rem;
  }
  .project-card h3 {
    font-size: 0.85rem;   /* smaller title */
    line-height: 1.2;
    white-space: nowrap;  /* keep titles to one line */
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Tiny phones: tighten spacing a touch more (still 4 per row) */
@media (max-width: 380px) {
  .projects {
    gap: 6px;
  }
  .project-card {
    padding: 0.5rem 0.4rem;
  }
  .project-card .project-icon {
    width: 40px;
  }
  .project-card h3 {
    font-size: 0.8rem;
  }
}

/* Reduced Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------------------------------------
   ✅ SAFARI SAFE AREA FIX — Black edges visible
---------------------------------------- */

/* Make sure html/body occupy full viewport */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* html draws black bars behind the notch & home bar */
html {
  background:
    #000 0 0 / 100% env(safe-area-inset-top, 0) no-repeat,
    #000 0 100% / 100% env(safe-area-inset-bottom, 0) no-repeat;
  background-color: var(--bg-color);
  background-attachment: fixed;
  position: relative;
  z-index: 0;
}

/* Body is elevated so the black shows behind */
body {
  position: relative;
  z-index: 1;
  font-family: var(--font-body);
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  color: var(--text-color);
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Header stays gradient and respects top safe area */
header {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff;
  text-align: center;
  padding: calc(2rem + env(safe-area-inset-top, 0)) 0 2rem 0;
}

/* Footer sits above bottom black bar */
footer {
  background: var(--primary-color);
  color: #fff;
  text-align: center;
  padding: 1.2rem 0 calc(env(safe-area-inset-bottom, 0) + 0.2rem);
  position: relative;
  z-index: 2;
}

/* Force Safari to render safe-area black even in full-screen view */
body::before,
body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  background: #000;
  z-index: -1;
}

body::before {
  top: 0;
  height: env(safe-area-inset-top, 0);
}

body::after {
  bottom: 0;
  height: env(safe-area-inset-bottom, 0);
}
