/* Page layout */
body {
  margin: 0;
  padding: 40px;
  background: #fdfdfd;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* Grid layout with named areas */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 180px);
  grid-template-areas:
    "vid vid vid vid"
    "plus minus multiply divide"
    "plusmin plusmin muldiv muldiv"
    "mix mix mix mix";
  gap: 20px;
  justify-content: center;
}

/* Base tile styling */
.tile {
  border-radius: 25px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  position: relative;
}

/* Hover animation */
.tile:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}

/* Image behavior */
.tile img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

/* ----- Video tile – now fixed height 180px like others ----- */
.vid {
  grid-area: vid;
  background: #fff5eb;
  background-image: radial-gradient(circle at 10% 20%, rgba(255,200,150,0.1) 0%, rgba(255,240,220,0.3) 90%);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  gap: 16px;
  width: auto;
  height: 70px;           /* fixed height – matches other tiles */
  box-sizing: border-box;
  overflow: hidden;        /* prevents content from spilling out */
}

.vid h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #c25b2e;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vid h3::before {
  content: "🎬";
  font-size: 1.3rem;
}

.video-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.lang-group {
  background: rgba(255,255,240,0.7);
  border-radius: 20px;
  padding: 4px 12px;
  backdrop-filter: blur(2px);
  font-size: 0.8rem;
}

.lang-group strong {
  display: inline-block;
  margin-right: 8px;
  font-size: 0.75rem;
  color: #b45a2e;
}

.lang-group ul {
  display: inline-block;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang-group li {
  display: inline-block;
  margin: 0 4px;
}

.vid a {
  text-decoration: none;
  font-weight: 500;
  background: #ffedd5;
  padding: 2px 10px;
  border-radius: 40px;
  display: inline-block;
  font-size: 0.8rem;
  color: #c75c2e;
  border: 1px solid #ffe0b5;
  transition: all 0.2s;
}

.vid a:hover {
  background: #ffd9a5;
  transform: translateY(-1px);
  color: #9b3e18;
}

/* Individual operation tiles */
.plus     { grid-area: plus;     background: #ffb3a7; }
.minus    { grid-area: minus;    background: #a7f0e4; }
.multiply { grid-area: multiply; background: #d7b3ff; }
.divide   { grid-area: divide;   background: #b3ffd9; }

.plusmin  {
  grid-area: plusmin;
  width: 380px;
  height: 180px;
  background: linear-gradient(135deg, #ffb3a7, #a7f0e4);
}

.muldiv   {
  grid-area: muldiv;
  width: 380px;
  height: 180px;
  background: linear-gradient(135deg, #d7b3ff, #b3ffd9);
}

.mix {
  grid-area: mix;
  width: 360px;
  height: 360px;
  margin: 0 auto;
  background: linear-gradient(135deg, #ffb3a7, #a7f0e4, #d7b3ff, #b3ffd9);
}

/* Make all square tiles use aspect ratio */
.tile:not(.plusmin):not(.muldiv):not(.mix):not(.vid) {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
}

/* Responsive layout for tablets */
@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, 180px);
    grid-template-areas:
      "vid vid"
      "plus minus"
      "multiply divide"
      "plusmin plusmin"
      "muldiv muldiv"
      "mix mix";
    gap: 16px;
  }

  .plusmin, .muldiv {
    width: 100%;
  }

  .mix {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .vid {
    height: auto;          /* allow taller on tablet if needed */
    min-height: 180px;
    flex-direction: column;
    align-items: flex-start;
  }

  .video-links {
    justify-content: flex-start;
  }
}

/* Responsive layout for phones */
@media (max-width: 500px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "vid"
      "plus"
      "minus"
      "multiply"
      "divide"
      "plusmin"
      "muldiv"
      "mix";
    gap: 16px;
  }

  .tile,
  .plusmin,
  .muldiv,
  .mix {
    width: 100%;
    height: auto;
  }

  .mix {
    aspect-ratio: 1 / 1;
  }

  .vid {
    height: auto;
    padding: 16px;
  }

  .video-links {
    flex-direction: column;
    gap: 8px;
  }
}
