@import url('https://fonts.googleapis.com/css2?family=Comic+Relief:wght@400;700&display=swap');

* {
  box-sizing: border-box;
  font-family: Comic Relief;
}
html, body {
  margin: 0;
}
body {
  background: #f7f9fc;
  color: #0b1220;
  line-height: 1.5;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem;
    /* Photo by Anna Tarazevich: https://www.pexels.com/photo/dawn-nature-sky-sunset-6712383/ */
  background-image: url("../images/background.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e4e7ef;
  background: linear-gradient(270deg, #ff9a9e, #fad0c4, #fbc2eb, #a1c4fd, #d4fc79, #96e6a1, #ff9a9e);
  background-size: 1400% 1400%;
  animation: gradientShift 20s ease-in-out infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

nav,
.top-nav ul {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav a,
.top-nav a {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: #0b1220;
  font-size: 2rem;
}

header nav a[aria-current="page"],
.top-nav a[aria-current="page"] {
  background: #eaf4ff;
  box-shadow: inset 0 0 0 1px #dbe6ff;
}

footer {
  border-top: 1px solid #e4e7ef;
  background: #fff;
  padding: 12px 16px;

  display: flex;
  justify-content: space-between; 
  align-items: center;           
}

footer .back-link {
  font-size: 1rem;
  text-decoration: none;
  color: #0b1220;
}

footer .back-link:hover {
  text-decoration: underline;
}

.logo {
  display: flex;
  align-items: center;
  gap: 3rem;
  font-size: 3rem;
}

.icon {
  width: 64px;
  height: 64px;
  display: block;
}

.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.skip {
  color: #56fa04;
}

.home-main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.5rem;
  font-size: 1rem;
  align-items: center;
}

.home-main > div {
  flex: 0 0 auto;
  width: clamp(320px, 90vw, 800px);
  min-height: clamp(200px, 26vh, 280px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: min(4vw, 2rem);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #e6e8f0;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  backdrop-filter: blur(2px);
  font-size: 1rem;
  line-height: 1.7;
}

.home-main > div p {
  max-width: 65ch;
  margin: 0;
  overflow-wrap: anywhere;
}

/* Animations */
.spinner {
  width: 156px;
  height: 156px;
  border: 10px solid #d8e2f1;
  border-top-color: #58e40d;
  border-radius: 50%;
  animation: spin 3s linear infinite;
  margin: 1rem auto;
  display: block;
  flex: 0 0 auto;
}

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

.pulse {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: #2b0c9bd0;
  box-shadow: 0 0 0 rgba(46,125,91,0.6);
  animation: pulse 2s ease-in-out infinite;
  margin: 1rem auto;
  display: block;
  flex: 0 0 auto;
}

@keyframes pulse {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(3,199,213,0.593); opacity: 1; }
  70%  { transform: scale(1.15); box-shadow: 0 0 0 18px rgba(231,2,243,0.347); opacity: 0.9; }
  100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(246,91,1,0.422); opacity: 1; }
}

#cards {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;         
}

.card {
  flex: 0 0 clamp(140px, 12vw, 200px);
  width: clamp(140px, 12vw, 200px);
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  border: 1px solid #e4e7ef;
  overflow: hidden;
  background-color: #fff;
  background-repeat: no-repeat;
  background-size: contain;        
  background-position: center;
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform, opacity;
  animation: slideLoop 5s ease-in-out infinite;
}

.card:nth-child(2) { 
  animation-delay: 0.33s; 
}

.card:nth-child(3) { 
  animation-delay: 0.66s; 
}

.card-ace   { 
  background-image: url("../images/ace-spades.png"); 
}

.card-king  { 
  background-image: url("../images/king-hearts.png"); 
}

.card-queen { 
  background-image: url("../images/queen-diamonds.png"); 
}

@keyframes slideLoop {
  0%   { opacity: 0;   transform: translate3d(0, 14px, 0); }
  15%  { opacity: 1;   transform: translate3d(0, 0, 0); }
  85%  { opacity: 1;   transform: translate3d(0, 0, 0); }
  100% { opacity: 0;   transform: translate3d(0, 14px, 0); }
}

details.code-example {
  margin: 0.5rem auto 1.5rem;
  width: auto;
  max-width: 100%;
}

details.code-example summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.25rem 0;
}

details.code-example[open] summary {
  margin-bottom: 0.5rem;
}

pre.code {
  display: inline-block;        
  max-width: 100%;              
  margin: 0 auto;               
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e4e7ef;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow: auto;               
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

pre.code > code {
  white-space: pre-wrap;        
  word-break: break-word;       
}

.wrapper {
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 100vh;
  padding: 1rem;
}

.video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #e6e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  overflow: hidden;
}

.video iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

#grid {
  width: 100%;
  table-layout: fixed;
  border-spacing: 12px;
}

#grid td { padding: 0; vertical-align: top; }

#grid img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

figure { margin: 0; }

figcaption {
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}

/* Mobile */
@media (max-width: 700px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 1rem;
  }

  nav,
  .top-nav ul {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    align-items: flex-start;
  }

  nav a,
  .top-nav a {
    width: 100%;
    font-size: 1rem;
  }

  main {
    flex-direction: column;
    gap: 1rem;
    padding: 12px;
  }

  main > div { 
    flex: none; 
    width: 100%; 
  }

  .logo { 
    margin-bottom: 0.5rem; 
  }

  #cards { 
    gap: 0.75rem; 
  }

  .card {
    flex: 1 1 calc(50% - 0.75rem);
    max-width: calc(50% - 0.75rem);
    aspect-ratio: 5 / 7;
    animation-duration: 4.5s;
  }

  #grid {
    display: block;
    width: 100%;
    border-spacing: 8px;
  }

  #grid tr { 
    display: block; 
    margin-bottom: 1rem; 
  }

  #grid td { 
    display: block; 
    width: 100%; 
    margin-bottom: 0.5rem; 
  }

  #grid img { 
    width: 100%; 
    height: auto; 
    display: block; 
    border-radius: 10px; 
  }

  figure { 
    margin: 0; 
  }

  figcaption { 
    text-align: center; 
    font-size: 0.9rem; 
    opacity: 0.85; 
    margin-top: 0.25rem; 
  }
}

/* Desktop */
@media (min-width: 900px) {
  .home-main {
    padding: 3rem 2rem;
    align-items: center;
    row-gap: 2.25rem;
  }

  .home-main h1 {
    font-size: clamp(2rem, 1.2rem + 2vw, 3rem);
    line-height: 1.15;
    margin: 0.25rem 0 0.75rem;
  }

  .home-main h2 {
    font-size: clamp(1.35rem, 1rem + 1vw, 1.75rem);
    line-height: 1.2;
    margin: 1.5rem 0 0.5rem;
  }

  .home-main p {
    font-size: 1.125rem;
    line-height: 1.75;
    letter-spacing: 0.01em;
    margin: 0 0 1rem;
    color: #0a0f1a;
  }

  .home-main > div {
    max-width: 70ch;
    padding: 1.25rem 1.5rem;
  }

  #cards {
    justify-content: center; 
    gap: 1.25rem;           
  }

  #cards .card {
    flex: 0 0 clamp(160px, 12vw, 220px);
    width: clamp(160px, 12vw, 220px);
    min-width: 160px;
    max-width: 220px;
    aspect-ratio: 5 / 7;
  }
}
