/* Nova 2048 — layout around the board, the forge ladder, the discovery card, the atlas. */

.nova {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: auto;
  grid-template-areas: "top" "board" "ladder";
  align-content: center;
  justify-content: center;
  justify-items: center;
  row-gap: 10px;
  padding: 6px 12px 4px;
}
.nova.is-row {
  grid-template-areas: "top board" "ladder board";
  grid-template-columns: var(--side, 240px) auto;
  grid-template-rows: 1fr 1fr;
  column-gap: 28px;
  row-gap: 14px;
  align-items: center;
}
.nova.is-row .nova-top { align-self: end; }
.nova.is-row .nova-ladder { align-self: start; }

.nova-top {
  grid-area: top;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}
.nova-modes {
  background: rgba(7, 13, 44, 0.72);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.nova-modes button {
  min-height: 36px;
  min-width: 96px;
  padding: 0 16px;
  font-size: 0.9rem;
  transition: background-color 0.2s linear, color 0.2s linear;
}
.nova-caption {
  max-width: 100%;
  min-height: 1.35em;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--mist);
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nova-board {
  grid-area: board;
  position: relative;
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(232, 182, 90, 0.08), 0 18px 48px rgba(2, 4, 20, 0.55), 0 0 80px rgba(36, 64, 184, 0.28);
}
.nova-board canvas {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  touch-action: none;
}

.nova-ladder {
  grid-area: ladder;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  min-height: 44px;
  padding: 2px 0 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: none;
}
.nova-next {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--mist);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.nova-ladder canvas { width: 100%; height: 30px; }
@media (hover: hover) {
  .nova-ladder:hover .nova-next { color: var(--parchment); }
}

/* dock */
.nova-dock { gap: 8px; }
.nova-act {
  flex: 0 1 auto;
  min-width: 0;
  padding: 0.6em 1em;
  gap: 6px;
}
.nova-act svg { width: 18px; height: 18px; }
.nova-act.is-off { opacity: 0.5; }
.nova-badge {
  position: absolute;
  top: -5px;
  right: -3px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--lapis);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
[dir="rtl"] .nova-badge { right: auto; left: -3px; }
.nova-act.is-off .nova-badge { background: var(--mist-dim); }

/* score pop */
#score-chip { position: relative; }
.nova-plus {
  position: absolute;
  top: 100%;
  left: 50%;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 750;
  color: var(--gold-soft);
  white-space: nowrap;
  pointer-events: none;
  animation: nova-plus 0.75s var(--ease-out) forwards;
}
@keyframes nova-plus {
  0% { opacity: 0; transform: translate(-50%, -8px) scale(0.9); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, 8px) scale(1); }
}

/* discovery card: slides up over the forge ladder and the dock, never over the board */
.nova-discover {
  position: fixed;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 13px 9px 9px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(27, 42, 116, 0.98) 0%, rgba(14, 24, 78, 0.98) 100%);
  box-shadow: 0 0 0 1px rgba(232, 182, 90, 0.5), 0 18px 44px rgba(0, 0, 0, 0.5);
  text-align: start;
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.2s linear, transform 0.38s var(--ease-out);
  touch-action: none;
}
[dir="rtl"] .nova-discover { padding: 9px 9px 9px 13px; }
.nova-discover[hidden] { display: none; }
.nova-discover.is-in { opacity: 1; transform: none; }
.nova-discover__art { flex: none; width: 54px; height: 54px; }
.nova-discover__text { flex: 1 1 auto; min-width: 0; }
.nova-discover__head {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 1px;
}
.nova-discover__name {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--parchment);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.nova-discover__val {
  margin-inline-start: 7px;
  font-family: var(--font-text);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
}
.nova-discover.is-narrow .nova-discover__art { display: none; }
.nova-discover.is-narrow { padding: 9px 13px; }
.nova-discover__eyebrow {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.nova-discover__fact {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.32;
  color: var(--mist);
}
html[lang="ar"] .nova-discover__eyebrow { letter-spacing: 0; text-transform: none; font-size: 11.5px; }

/* panels */
.nova-end .fa-panel__art canvas { filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45)); }
.nova-forged { margin: -2px 0 0; color: var(--mist); }
.nova-forged strong { color: var(--gold-soft); font-weight: 650; }
.nova-panel-fact { margin: -4px auto 0; max-width: 28em; color: var(--mist); font-size: 0.95rem; }

.nova-intro { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 2px 0 4px; }
.nova-intro__arrow {
  width: 7px;
  height: 7px;
  border-top: 2px solid var(--gold);
  border-right: 2px solid var(--gold);
  transform: rotate(45deg);
  opacity: 0.8;
}
[dir="rtl"] .nova-intro__arrow { transform: rotate(-135deg); }

.nova-atlas-overlay .fa-panel { max-width: 420px; padding-bottom: 18px; }
.nova-progress {
  height: 6px;
  margin: 0 4px 14px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(242, 234, 216, 0.08);
}
.nova-progress span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }
[dir="rtl"] .nova-progress span { margin-left: auto; background: linear-gradient(270deg, var(--gold), var(--gold-soft)); }
.nova-atlas { display: grid; gap: 8px; text-align: start; }
.nova-atlas__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(242, 234, 216, 0.045);
}
.nova-atlas__item.is-current { box-shadow: inset 0 0 0 1px rgba(232, 182, 90, 0.45); }
.nova-atlas__item canvas { flex: none; }
.nova-atlas__text { min-width: 0; }
.nova-atlas__name { font-weight: 650; color: var(--parchment); line-height: 1.25; }
.nova-atlas__val {
  margin-inline-start: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
}
.nova-atlas__fact { margin-top: 2px; font-size: 13px; line-height: 1.38; color: var(--mist); }
.nova-atlas__item.is-unknown { background: rgba(242, 234, 216, 0.02); }
.nova-atlas__item.is-unknown .nova-atlas__name { color: var(--mist-dim); }
.nova-atlas__item.is-unknown .nova-atlas__fact { color: var(--mist-dim); }

/* small phones */
@media (max-width: 360px) {
  .fa-bar { gap: 6px; padding: 0 4px; }
  .fa-title { font-size: 1rem; }
  .nova-modes button { min-width: 84px; padding: 0 12px; font-size: 0.86rem; }
  .nova-act { padding: 0.6em 0.85em; font-size: 0.88rem; }
  .nova-discover__fact { font-size: 12.5px; }
}

/* short landscape phones: the dock becomes a side rail so the board can be as tall as possible */
@media (orientation: landscape) and (max-height: 500px) {
  .nova-dock {
    position: absolute;
    top: calc(var(--safe-t) + var(--bar-h));
    right: var(--safe-r);
    bottom: var(--safe-b);
    width: 124px;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding: 8px 14px 8px 0;
  }
  [dir="rtl"] .nova-dock { right: auto; left: var(--safe-l); padding: 8px 0 8px 14px; }
  .nova-dock .nova-act { width: 100%; }
  .fa-stage { margin-right: 124px; }
  [dir="rtl"] .fa-stage { margin-right: 0; margin-left: 124px; }
}

/* short landscape phones: end and intro panels go two-column so every button is visible without scrolling */
@media (orientation: landscape) and (max-height: 500px) {
  .nova-end .fa-panel,
  .nova-intro-panel .fa-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "art stats" "eyebrow stats" "title actions" "body actions";
    column-gap: 24px;
    align-items: center;
    max-width: 660px;
    padding: 16px 20px 16px;
  }
  .nova-intro-panel .fa-panel { grid-template-areas: "art body" "eyebrow body" "title body" "text actions"; }
  .nova-end .fa-panel__art, .nova-intro-panel .fa-panel__art { grid-area: art; margin: 0 0 4px; }
  .nova-end .fa-panel__art canvas { width: 60px !important; height: 60px !important; }
  .nova-intro-panel .fa-panel__art canvas { width: 40px !important; height: 40px !important; }
  .nova-end .fa-panel__eyebrow, .nova-intro-panel .fa-panel__eyebrow { grid-area: eyebrow; }
  .nova-end .fa-panel__title, .nova-intro-panel .fa-panel__title { grid-area: title; margin: 2px 0 4px; font-size: 1.5rem; }
  .nova-end .fa-panel__body { grid-area: body; margin: 0; }
  .nova-intro-panel .fa-panel__body { grid-area: body; margin: 0; }
  .nova-intro-panel .fa-panel__text { grid-area: text; margin: 0; font-size: 0.92rem; }
  .nova-intro-panel .fa-howto { margin: 0; gap: 6px; font-size: 0.92rem; }
  .nova-end .fa-stats { grid-area: stats; align-self: end; margin: 0 0 10px; }
  .nova-end .fa-stats > div { padding: 6px 4px 5px; }
  .nova-end .fa-stats dd { font-size: 1.2rem; }
  .nova-end .fa-panel__actions, .nova-intro-panel .fa-panel__actions { grid-area: actions; align-self: start; gap: 8px; }
  .nova-end .fa-btn, .nova-intro-panel .fa-btn { min-height: 44px; padding: 0.6em 1em; }
  .nova-panel-fact { font-size: 0.85rem; margin: 0; }
  .nova-discover__fact { font-size: 12.5px; }
}
