/* ═══════════════════════════════════════════════════════════════
   EcoGames — Impact Stories  |  style.css
   Single-screen layout, offline-only, no external dependencies.
   Desktop is the primary target; mobile breakpoint at 640px.
   ═══════════════════════════════════════════════════════════════ */


/* ── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img {
  display: block;
}


/* ── Base / background ──────────────────────────────────────── */

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;            /* single screen — no scroll */
}

body {
  font-family: 'Arial Rounded MT Bold', Arial, sans-serif;
  color: #305372;
  /* ocean watercolour wash; #c2d9e4 is a close solid fallback */
  background-color: #c2d9e4;
  background-image: url('assets/ui/background.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}


/* ── App shell (full-viewport flex column) ──────────────────── */

.app {
  display: flex;
  flex-direction: column;
  height: 100svh;
  padding: 40px clamp(12px, 3vw, 44px) 10px;  /* horizontal padding shrinks at narrow widths */
  gap: 6px;
  overflow: hidden;  /* clips content cleanly rather than showing scrollbars */
}


/* ═══════════════════════════════════════════════════════════════
   HEADER  —  three-column grid: logotype | title | button
   ═══════════════════════════════════════════════════════════════ */

.header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 20px;
  flex-shrink: 0;
}


/* Left column — logotype + tagline + language flags */

.header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.logotype {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  margin-bottom: 2px;
}

.logo-line {
  /* "Impact" then "Stories" stacked — ocean blue, prominent size */
  font-size: clamp(22px, 2.8vw, 38px);
  font-weight: bold;
  color: #5394A7;
  letter-spacing: -0.01em;
}

.tagline {
  font-size: clamp(9px, 0.85vw, 12px);
  color: #5394A7;
  font-weight: normal;
  line-height: 1.35;
  max-width: 148px;
}

/* Language flag toggle */

.language-toggle {
  display: flex;
  width: 100%;                /* stretch to column width so flags can right-align */
  justify-content: flex-end;  /* push flags to the right edge */
  gap: 5px;
}

/* Single language toggle button — shows active language flag */

.lang-toggle {
  background: none;
  border: none;
  padding: 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s ease;
  display: block;
}

/* In the desktop right column, stretch to column width and push flag right */
.header-right .lang-toggle {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;  /* space between flag and deal button */
}

.lang-toggle:hover {
  opacity: 0.75;
}

.lang-toggle img {
  width: 34px;
  height: auto;
  border-radius: 3px;
  display: block;
}


.header-center {
  text-align: center;
}

.instruction {
  text-align: center;
  font-size: clamp(11px, 1.05vw, 15px);
  color: #5394A7;
  font-weight: normal;
  margin-top: 4px;
}

.topic-title {
  /* Deliberately large — dominant element on screen */
  font-size: clamp(52px, min(9.5vw, 14vh), 110px);
  font-weight: bold;
  color: #305372;
  line-height: 1;
  white-space: nowrap;
}


/* Right column — "Deal Cards Now!" button */

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 24px;
}

.deal-button {
  font-family: 'Arial Rounded MT Bold', Arial, sans-serif;
  font-size: clamp(13px, 1.35vw, 18px);
  font-weight: bold;
  color: #ffffff;
  background-color: #5394A7;
  border: none;
  border-radius: 50px;               /* pill shape to match mockup */
  padding: clamp(10px, 1.4vh, 16px) clamp(18px, 2.2vw, 34px);
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.deal-button:hover {
  background-color: #437e91;
}

.deal-button:disabled {
  opacity: 0.6;
  cursor: default;
}





/* ═══════════════════════════════════════════════════════════════
   CARD GRID  —  4 columns × 2 rows, fills remaining space
   ═══════════════════════════════════════════════════════════════ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: clamp(4px, 0.9vw, 14px);  /* gap also shrinks at narrow widths */
  flex: 1;
  min-height: 0;
  min-width: 0;   /* prevents grid from overflowing its flex parent */
  margin-top: clamp(6px, 1vh, 12px);
  margin-bottom: clamp(6px, 1vh, 12px);
}

.card-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  -webkit-perspective: 800px;
          perspective: 800px;
}

/* card-inner is the element that physically flips.
   Uses aspect-ratio to maintain card proportions at any slot size. */
.card-inner {
  position: relative;
  /* Fill available space but respect the card's natural 358:402 aspect ratio */
  width: 100%;
  height: 100%;
  max-width: calc(100vh * (358 / 402));  /* never wider than height allows */
  aspect-ratio: 358 / 402;              /* maintains card proportions */
  -webkit-transform-style: preserve-3d;
          transform-style: preserve-3d;
  transition: transform 0.4s ease-in-out;
}

/* Faster transition used when flipping back to empty state between rounds */
.card-inner.resetting {
  transition-duration: 0.2s;
}

/* When .flipped is added by JS, rotate to reveal the front face */
.card-inner.flipped {
  -webkit-transform: rotateY(180deg);
          transform: rotateY(180deg);
}

/* Both faces share the same position, stacked on top of each other */
.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;  /* hide the face when it's pointing away */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Front face starts rotated 180deg so it's hidden until flipped */
.card-front {
  -webkit-transform: rotateY(180deg);
          transform: rotateY(180deg);
}

/* Back face (question mark) starts visible */
.card-back {
  -webkit-transform: rotateY(0deg);
          transform: rotateY(0deg);
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;  /* scale to fit without cropping */
  display: block;
}


/* ═══════════════════════════════════════════════════════════════
   STORY PROMPT BAR
   ═══════════════════════════════════════════════════════════════ */

.prompt-area {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid #5394A7;
  border-radius: 50px;
  padding: clamp(12px, 1.8vh, 22px) 52px;
  text-align: center;
  min-height: clamp(52px, 8vh, 80px);  /* prevents box shrinking when text is cleared */
  display: flex;
  align-items: center;
  justify-content: center;
}

.prompt-text {
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: bold;
  color: #305372;
}


/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */

.footer {
  flex-shrink: 0;
  text-align: center;
  padding-bottom: 2px;
}

.footer-text {
  font-size: clamp(10px, 0.85vw, 13px);
  color: #666666;
  font-weight: normal;
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer-logo {
  height: clamp(14px, 1.6vh, 22px);
  width: auto;
  margin-left: 5px;
}


/* ═══════════════════════════════════════════════════════════════
   SHOW / HIDE HELPERS
   desktop-only: visible on desktop, hidden on mobile
   mobile-only:  visible on mobile, hidden on desktop
   ═══════════════════════════════════════════════════════════════ */

/* Hide mobile-only elements on desktop */
.mobile-only { display: none; }

/* Hide desktop-only elements on mobile (set below in breakpoint) */
.desktop-only { display: block; }


/* ═══════════════════════════════════════════════════════════════
   MOBILE  —  partner demo layout, ≤640px wide
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {

  /* Allow vertical scrolling on mobile */
  html, body {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
    padding: 36px 16px 24px;  /* top headroom; bottom padding for footer */
    gap: 10px;
    /* no justify-content — elements stack naturally from top; footer pushed down by margin-top: auto */
  }

  /* ── Show/hide helpers ── */
  .mobile-only  { display: block; }   /* reveal mobile-only elements */
  .desktop-only { display: none; }    /* hide desktop-only elements */

  /* ── Header: two columns — logotype left, Ocean right ── */
  .header {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto;
    align-items: start;
    column-gap: 12px;
  }

  /* header-left: logotype + tagline stacked, no flags */
  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .logo-line { font-size: clamp(16px, 4.5vw, 22px); }

  .tagline {
    font-size: clamp(8px, 2.5vw, 11px);
    max-width: 110px;
  }

  /* header-center: Ocean left, flags right, aligned to top */
  .header-center {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
  }

  .topic-title {
    font-size: clamp(48px, 16vw, 72px);
    white-space: normal;
    flex: 1;
  }

  /* Mobile flag toggle sits top-right of header-center */
  .lang-toggle.mobile-only {
    display: block;
    margin: 4px 0 0 8px;
    flex-shrink: 0;
  }

  /* ── Mobile deal button: full width, pill shape ── */
  .deal-button-mobile {
    display: block;
    width: 100%;
    text-align: center;
    font-size: clamp(16px, 4.5vw, 20px);
    padding: 14px 20px;
    border-radius: 50px;
    margin-top: 16px;  /* breathing room between header and button */
  }

  /* ── Instruction lines ── */
  .instruction {
    text-align: center;
    font-size: clamp(12px, 3.5vw, 15px);
    margin-top: 0;
  }

  /* ── Card grid ── */
  .card-grid {
    flex: unset;               /* size from content so row-gap stays a true 8px */
    grid-template-rows: 1fr 1fr;  /* equal rows; prevents vertical stretching of gap */
    column-gap: 8px;           /* horizontal gap between cards */
    row-gap: 8px;              /* vertical gap between rows — matches column gap */
  }

  /* Enforce card aspect ratio so rows size correctly */
  .card-slot {
    aspect-ratio: 358 / 402;
  }

  /* ── Prompt area: larger text, more padding, rounded rectangle ── */
  .prompt-area {
    border-radius: 20px;
    padding: 36px 20px;        /* taller box to match mockup prominence */
    border: 2px solid #5394A7;
    background: rgba(255, 255, 255, 0.90);
    min-height: 140px;         /* prevents box shrinking when text is cleared */
  }

  .prompt-text {
    font-size: clamp(20px, 6vw, 28px);
  }

  /* ── Footer ── */
  .footer {
    padding-bottom: 16px;
    padding-top: 8px;
    margin-top: auto;  /* pushes footer to bottom of screen; everything above stacks naturally */
  }

  .footer-text {
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }

  .footer-logo {
    height: 28px;
  }
}
