/* Landing page — overrides portal_layout's locked-scroll + light theme. */

html, body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
body {
  background: #03040a;
  color: #fff;
  font-family: -apple-system, system-ui, "Helvetica Neue", sans-serif;
}

.landing {
  /* Everything scales from this one value. All other measurements
     (bento size, gaps, padding, label) derive from it via the
     portal_layout.css custom properties. */
  --app-icon-size: 1.6rem;
  /* Double the default bento inset (0.30 × icon-size → 0.60). This
     shows up as extra padding around the grid inside each box and
     automatically widens/heightens .landing-box via the calc. */
  --app-group-inset: calc(var(--app-icon-size) * 0.60);

  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 40px clamp(24px, 5vw, 72px) 80px;
}

/* ---- Starry night sky ---- */
.sky {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 30% 15%, rgba(60, 40, 120, 0.55), transparent 60%),
    radial-gradient(ellipse 70% 55% at 75% 85%, rgba(20, 50, 120, 0.55), transparent 60%),
    linear-gradient(180deg, #050617 0%, #080a1e 45%, #03040e 100%);
}
.stars {
  position: absolute; inset: -50%;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at 27% 62%, #cfd8ff, transparent 60%),
    radial-gradient(1.6px 1.6px at 41% 29%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at 55% 77%, #eef2ff, transparent 60%),
    radial-gradient(1.2px 1.2px at 68% 12%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at 82% 48%, #c9d2ff, transparent 60%),
    radial-gradient(1.8px 1.8px at 91% 72%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at  6% 84%, #dfe5ff, transparent 60%),
    radial-gradient(1.2px 1.2px at 34% 92%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at 49% 8%,  #cbd5ff, transparent 60%),
    radial-gradient(1.4px 1.4px at 73% 38%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at 88% 22%, #e6ebff, transparent 60%),
    radial-gradient(1.6px 1.6px at 18% 48%, #ffffff, transparent 60%),
    radial-gradient(1px   1px   at 62% 56%, #d3dcff, transparent 60%);
  background-size: 420px 420px;
  background-repeat: repeat;
  opacity: 0.9;
  animation: twinkle 6s ease-in-out infinite alternate;
}
.stars.layer-2 {
  background-size: 680px 680px;
  opacity: 0.55;
  animation-duration: 9s;
  animation-delay: -3s;
}
@keyframes twinkle {
  0%   { opacity: 0.55; }
  50%  { opacity: 0.95; }
  100% { opacity: 0.65; }
}

/* ---- Breadcrumb logo ---- */
.site-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px; font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: clamp(40px, 7vh, 96px);
}
/* ---- Error page (404 / 500 / etc.) ---- */
.landing-error {
  margin: auto;
  text-align: center;
  transform: translateY(-6vh);
  padding: 0 24px;
}
.landing-error__code {
  font-size: clamp(120px, 20vw, 260px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  color: #fff;
  text-shadow: 0 4px 60px rgba(0, 0, 0, 0.5);
}
.landing-error__tagline {
  margin-top: 16px;
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
}
.landing-error__actions {
  margin-top: clamp(36px, 5vh, 64px);
  display: flex;
  justify-content: center;
  gap: clamp(16px, 3vw, 32px);
  flex-wrap: wrap;
}
.landing-error__btn {
  font-size: 20px;
  font-weight: 500;
  color: #0a84ff;
  text-decoration: none;
  text-shadow: 0 0 18px rgba(10, 132, 255, 0.45);
  transition: color 0.3s ease;
}
.landing-error__btn:hover {
  color: #409cff;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 0.06em;
}

/* ---- Bento row ---- */
.landing-bento {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(32px, 6vw, 96px);
  flex-wrap: wrap;
  margin: auto;
  transform: translateY(-6vh);
}

.landing-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Bento box. Size derives from:
   (cols × --app-icon-size-2x2) + gaps + 2 × inset. */
.landing-box {
  position: relative;
  border-radius: var(--launchpad-group-radius);
  background: #0b0d20;
  border: 1px solid rgba(255, 255, 255, 0.22);
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 30px 60px -20px rgba(0, 0, 0, 0.75),
    0 60px 120px -30px rgba(0, 0, 0, 0.6),
    0 0 120px -10px rgba(80, 120, 255, 0.18);
  /* Width fits the icon grid columns + inset. Uses --box-cols so
     individual items can override (e.g. connect-4 grows to 7 when
     the game is active); falls back to --landing-cols otherwise. */
  width: calc(
    (2 * var(--app-group-inset)) +
    (var(--box-cols, var(--landing-cols)) * var(--app-icon-size-2x2)) +
    ((var(--box-cols, var(--landing-cols)) - 1) * var(--inter-icon-spacing))
  );
  transition: width 0.55s cubic-bezier(.5, .1, .4, 1);
  /* Height fits all rows fully. */
  height: calc(
    (2 * var(--app-group-inset)) +
    (var(--landing-rows) * var(--app-icon-size-2x2)) +
    ((var(--landing-rows) - 1) * var(--inter-icon-spacing))
  );
}

/* Icon grid layer. Positioned above the wallpaper/tint pseudo-elements. */
.landing-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(var(--landing-cols), var(--app-icon-size-2x2));
  grid-template-rows:    repeat(var(--landing-rows), var(--app-icon-size-2x2));
  gap: var(--inter-icon-spacing);
  padding: var(--app-group-inset);
}

/* Blurred wallpaper + tint behind the icons. */
.landing-box::before,
.landing-box::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
}
.landing-box::before {
  background-image: var(--landing-wall);
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(1.2) brightness(0.95);
  transform: scale(1.15);
  z-index: 0;
}
.landing-box::after {
  background:
    radial-gradient(ellipse at 50% 110%, rgba(0,0,0,0.55), transparent 65%),
    linear-gradient(180deg, rgba(10,12,30,0.10) 0%, rgba(10,12,30,0.38) 100%);
  z-index: 1;
}

.landing-icon {
  position: relative;
  z-index: 2;
  width: var(--app-icon-size-2x2);
  height: var(--app-icon-size-2x2);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ---- Minesweeper (apps bento) ---- */
#ms-board { user-select: none; }
#ms-board .ms-tile { cursor: pointer; }

.ms-tile--revealed {
  background-image: none !important;
}
.ms-tile--revealed::after {
  content: attr(data-n);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--app-icon-size-2x2) * 0.72);
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 1;
  filter: none;
}
.ms-tile--revealed[data-n="0"]::after { content: ""; }
.ms-tile--revealed[data-n="1"]::after { color: #4aa5ff; }
.ms-tile--revealed[data-n="2"]::after { color: #5ed881; }
.ms-tile--revealed[data-n="3"]::after { color: #ff6b5e; }
.ms-tile--revealed[data-n="4"]::after { color: #bf5af2; }
.ms-tile--revealed[data-n="5"]::after { color: #ff9f0a; }
.ms-tile--revealed[data-n="6"]::after { color: #64d2ff; }
.ms-tile--revealed[data-n="7"]::after { color: #ffd60a; }
.ms-tile--revealed[data-n="8"]::after { color: #f2f2f7; }

.ms-tile--flagged::before {
  content: "🚩";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6%;
  font-size: calc(var(--app-icon-size-2x2) * 0.6);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.ms-tile--mine-shown,
.ms-tile--exploded {
  background-image: none !important;
}
.ms-tile--mine-shown::before,
.ms-tile--exploded::before {
  content: "💣";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--app-icon-size-2x2) * 0.65);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

@keyframes ms-mine-shown {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.ms-tile--mine-shown { animation: ms-mine-shown 0.35s ease forwards; }

@keyframes ms-explode {
  0%   { transform: scale(1)   rotate(0);     opacity: 1;
         filter: brightness(1) drop-shadow(0 0 0 rgba(255, 80, 40, 0)); }
  35%  { transform: scale(1.8) rotate(14deg); opacity: 1;
         filter: brightness(2.2) hue-rotate(20deg)
                 drop-shadow(0 0 28px rgba(255, 100, 40, 0.95)); }
  100% { transform: scale(0.3) rotate(-24deg); opacity: 0;
         filter: brightness(2) drop-shadow(0 0 40px rgba(255, 80, 40, 1)); }
}
.ms-tile--exploded { animation: ms-explode 0.65s cubic-bezier(.3,0,.7,.3) forwards; }

@keyframes ms-win-pulse {
  0%, 100% { filter: none; }
  50%      { filter: drop-shadow(0 0 16px rgba(100, 220, 150, 0.9))
                     brightness(1.4); }
}
.ms-tile--won { animation: ms-win-pulse 1.2s ease-in-out infinite; }

/* ---- Connect Four (games bento) ---- */
/* The c4 board always renders c4_cols columns, but in idle mode the
   parent .landing-item's --box-cols is ms_cols so the extra (last)
   column is hidden. When JS starts the game it flips --box-cols to
   c4_cols and adds .c4-active, which reveals the extra column. */
#c4-board {
  user-select: none;
  grid-template-columns: repeat(var(--box-cols), var(--app-icon-size-2x2)) !important;
}
#c4-board .c4-cell { cursor: pointer; transition: opacity 0.4s ease; }
#c4-board .c4-cell--extra { display: none; }
#c4-board.c4-active .c4-cell--extra { display: block; }

/* Once the game starts, every cell fades out; filled cells fade
   back in (they're the falling tokens). Pointer events stay on
   so empty slots are still clickable for column selection. */
#c4-board.c4-active .c4-cell { opacity: 0; }
#c4-board.c4-active .c4-cell.c4-filled { opacity: 1; }

/* Fall animation: token starts 7 row-heights above its resting
   slot and accelerates down, with a small settle bounce. */
@keyframes c4-drop {
  0%   { transform: translateY(-720%); }
  78%  { transform: translateY(0); }
  88%  { transform: translateY(-10%); }
  100% { transform: translateY(0); }
}
.c4-dropping { animation: c4-drop 0.6s cubic-bezier(.35, 0, .65, .55) forwards; }

@keyframes c4-win-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(100, 220, 150, 0)); }
  50%      { filter: drop-shadow(0 0 18px rgba(100, 220, 150, 0.95))
                     brightness(1.35); }
}
@keyframes c4-lose-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 80, 80, 0)); }
  50%      { filter: drop-shadow(0 0 18px rgba(255, 80, 80, 0.95))
                     brightness(1.2); }
}
.c4-winning { animation: c4-win-pulse  1.1s ease-in-out infinite; }
.c4-losing  { animation: c4-lose-pulse 1.1s ease-in-out infinite; }

.landing-label {
  display: block;
  margin-top: calc(var(--app-icon-size) * 0.9);
  font-size: calc(var(--app-icon-size) * 1.6);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: #fff;
  text-decoration: none;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
  transition: text-shadow 0.5s cubic-bezier(.2,.8,.2,1),
              color 0.5s cubic-bezier(.2,.8,.2,1);
}
.landing-visit {
  display: block;
  margin-top: 0.35em;
  font-size: calc(var(--app-icon-size) * 0.55);
  font-weight: 500;
  color: #0a84ff;
  text-decoration: none;
  text-shadow: 0 0 18px rgba(10, 132, 255, 0.45);
  transition: color 0.3s ease;
}
.landing-visit:hover {
  color: #409cff;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 0.06em;
}

.landing-label:hover {
  color: #fff;
  text-shadow:
    0 0 12px rgba(255, 255, 255, 0.9),
    0 0 32px rgba(180, 200, 255, 0.85),
    0 0 64px rgba(120, 160, 255, 0.7),
    0 0 120px rgba(120, 160, 255, 0.5);
}

/* ---- Auth (sign in / register) ----
   Centered translucent card on the same starry night background as
   the landing/error pages. Used by /login, /accounts_users/log-in,
   and /accounts_users/register. */
.landing-auth {
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 40px clamp(24px, 4vw, 40px);
  background: rgba(12, 14, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(-4vh);
}

.landing-auth__title {
  margin: 0 0 28px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  text-align: center;
}

.landing-auth__error {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(255, 80, 80, 0.35);
  border-radius: 10px;
  color: #ffb3b3;
  font-size: 14px;
  text-align: center;
}

.landing-auth__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.landing-auth__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.landing-auth__field > span {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.01em;
}

.landing-auth__field > input {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.landing-auth__field > input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.landing-auth__field > input:focus {
  outline: none;
  border-color: rgba(10, 132, 255, 0.7);
  background: rgba(255, 255, 255, 0.10);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.landing-auth__remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  cursor: pointer;
}

.landing-auth__remember > input {
  accent-color: #0a84ff;
}

.landing-auth__submit {
  margin-top: 8px;
  padding: 12px 16px;
  background: #0a84ff;
  border: none;
  border-radius: 10px;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.35);
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.landing-auth__submit:hover {
  background: #2a93ff;
}

.landing-auth__submit:active {
  transform: translateY(1px);
}

.landing-auth__hint {
  margin: 18px 0 0;
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
}

.landing-auth__hint a {
  color: #0a84ff;
  text-decoration: none;
  text-shadow: 0 0 12px rgba(10, 132, 255, 0.35);
}

.landing-auth__hint a:hover {
  color: #409cff;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
