/* StarCraft: Ashfall — enhancement layer styles
 *
 * LAYOUT CONTRACT: the base game locks the document with `overflow: hidden`
 * and positions its deployment controls in normal flow down the left side.
 * Measured at 1440x900, the "部署小队" button sits at x 45-469 / y 565-637.
 * An earlier build docked this drawer on the LEFT, where its panel covered that
 * button and made the game unstartable (elementFromPoint returned the panel, so
 * the click never landed). So: dock to the RIGHT, stay position:fixed, and
 * never join the document flow.
 */

/* ---- right-edge launcher tab: fixed, collapsed by default ---- */
.ashfall-dock {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 60;
  transform: translateY(-50%);
  font-family: inherit;
}

.ashfall-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  width: 2.1rem;
  padding: .7rem .3rem;
  border: 1px solid rgba(119, 214, 255, .38);
  border-right: none;
  border-radius: 6px 0 0 6px;
  background: rgba(6, 17, 26, .9);
  color: #9fe4ff;
  font: 600 .62rem/1.15 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .06em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}

.ashfall-toggle:hover { color: #eaf6ff; border-color: rgba(119, 214, 255, .7); }
.ashfall-toggle b { font-size: .82rem; line-height: 1; }
.ashfall-toggle small {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: rgba(212, 231, 243, .66);
  font-size: .58rem;
}
.ashfall-dock.is-open .ashfall-toggle { border-color: #77d6ff; color: #eaf6ff; }

/* ---- the panel: fixed overlay, slides in from the right ---- */
.ashfall-extension {
  position: fixed;
  top: 50%;
  right: 2.4rem;
  z-index: 59;
  width: min(34rem, calc(100vw - 3.5rem));
  max-height: min(80vh, 42rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(-50%) translateX(105%);
  opacity: 0;
  visibility: hidden;
  padding: 1rem;
  border: 1px solid rgba(119, 214, 255, .25);
  background: linear-gradient(135deg, rgba(8, 20, 31, .97), rgba(13, 27, 42, .93));
  box-shadow: 0 12px 35px rgba(0, 0, 0, .45), inset 0 1px rgba(255, 255, 255, .05);
  color: #eaf6ff;
  font-family: inherit;
  transition: transform .22s ease, opacity .22s ease, visibility .22s;
}

.ashfall-dock.is-open .ashfall-extension {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  visibility: visible;
}

.ashfall-extension-head,
.ashfall-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.ashfall-extension-head h2 {
  margin: .2rem 0 0;
  font-size: 1.15rem;
  letter-spacing: .08em;
}

.ashfall-kicker,
.ashfall-block-head small,
.ashfall-commander-copy small,
.ashfall-commander-copy i,
.ashfall-army-details summary small,
.ashfall-live {
  display: block;
  color: rgba(212, 231, 243, .62);
  font-size: .68rem;
  letter-spacing: .04em;
}

.ashfall-close {
  border: 1px solid rgba(213, 234, 247, .18);
  background: rgba(255, 255, 255, .05);
  color: #cfe6f4;
  font: 600 .68rem/1 ui-sans-serif, system-ui, sans-serif;
  padding: .4rem .55rem;
  cursor: pointer;
}
.ashfall-close:hover { color: #fff; border-color: rgba(213, 234, 247, .4); }
.ashfall-return { display: none; }

.ashfall-live {
  margin: .6rem 0 .9rem;
  color: #8fe5bf;
  white-space: nowrap;
}
.ashfall-live i {
  display: inline-block;
  width: .42rem;
  height: .42rem;
  margin-right: .3rem;
  border-radius: 50%;
  background: #8fe5bf;
  box-shadow: 0 0 10px #8fe5bf;
}

.ashfall-block { margin-top: 1rem; min-width: 0; }
.ashfall-block-head { margin-bottom: .55rem; }
.ashfall-block-head b { font-size: .78rem; letter-spacing: .08em; }

/* ---- difficulty ---- */
.ashfall-difficulty-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
}

.ashfall-difficulty,
.ashfall-commander-card {
  min-width: 0;
  border: 1px solid rgba(213, 234, 247, .14);
  background: rgba(255, 255, 255, .035);
  color: inherit;
  text-align: left;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}

.ashfall-difficulty { padding: .55rem; cursor: pointer; }
.ashfall-difficulty:hover { transform: translateY(-2px); border-color: var(--accent, #77d6ff); }
.ashfall-difficulty.is-active {
  border-color: var(--accent, #77d6ff);
  background: color-mix(in srgb, var(--accent, #77d6ff) 12%, transparent);
}
.ashfall-difficulty b { display: block; color: var(--accent, #77d6ff); font-size: .8rem; }
.ashfall-difficulty small {
  display: block;
  margin-top: .25rem;
  color: rgba(232, 245, 253, .68);
  font-size: .62rem;
  line-height: 1.4;
}

/* ---- mutator mirror: shows which modifiers the active tier uses ---- */
.ashfall-mutator-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.ashfall-mut {
  padding: .2rem .5rem;
  border: 1px solid rgba(213, 234, 247, .16);
  border-radius: 999px;
  color: rgba(212, 231, 243, .45);
  font-size: .62rem;
  letter-spacing: .04em;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.ashfall-mut.is-on {
  border-color: rgba(255, 111, 114, .55);
  background: rgba(255, 111, 114, .14);
  color: #ffc9c9;
}

/* ---- commanders ---- */
.ashfall-commander-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.ashfall-commander-card { display: flex; gap: .55rem; padding: .45rem; cursor: pointer; }
.ashfall-commander-card:hover { transform: translateY(-2px); border-color: #77d6ff; }
.ashfall-commander-card.is-active { border-color: #f5c96a; background: rgba(245, 201, 106, .1); }
.ashfall-commander-card img {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, .18);
}
.ashfall-commander-copy { min-width: 0; }
.ashfall-commander-copy b { display: block; font-size: .8rem; }
.ashfall-commander-copy i {
  overflow: hidden;
  margin-top: .15rem;
  font-style: normal;
  line-height: 1.35;
}

/* ---- per-commander roster ---- */
.ashfall-army-details {
  margin-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding-top: .7rem;
}
.ashfall-army-details summary {
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}
.ashfall-army-details summary::-webkit-details-marker { display: none; }

.ashfall-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
  gap: .45rem;
  margin-top: .65rem;
}
.ashfall-unit { margin: 0; text-align: center; }
.ashfall-unit img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(213, 234, 247, .16);
  background: rgba(255, 255, 255, .03);
}
.ashfall-unit figcaption {
  margin-top: .25rem;
  color: rgba(232, 245, 253, .78);
  font-size: .6rem;
  line-height: 1.25;
}

/* ---- FPS badge: decorative, must never intercept a click ---- */
.ashfall-fps {
  position: fixed;
  right: .75rem;
  bottom: .75rem;
  z-index: 50;
  display: flex;
  align-items: baseline;
  gap: .35rem;
  padding: .35rem .55rem;
  border: 1px solid rgba(143, 229, 191, .35);
  background: rgba(6, 17, 26, .82);
  color: #8fe5bf;
  font: 600 .68rem/1.1 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.ashfall-fps b { font-size: .88rem; }
.ashfall-fps small { color: rgba(232, 245, 253, .6); font-size: .58rem; }
.ashfall-fps[data-level="mid"] { color: #f5c96a; border-color: rgba(245, 201, 106, .35); }
.ashfall-fps[data-level="low"] { color: #ff8585; border-color: rgba(255, 111, 114, .4); }

@media (max-width: 850px) {
  #welcome #start-button {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
  }
  .ashfall-toggle { min-width: 44px; min-height: 88px; }
  .ashfall-close { min-width: 60px; min-height: 44px; touch-action: manipulation; }
  .ashfall-difficulty-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ashfall-commander-grid { grid-template-columns: 1fr; }
  .ashfall-extension {
    box-sizing: border-box;
    right: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }
  .ashfall-extension-head {
    position: sticky;
    top: -1rem;
    z-index: 2;
    padding: .5rem 0;
    background: #0a1724;
  }
  .ashfall-live { white-space: normal; line-height: 1.5; }
  .ashfall-return {
    display: block;
    position: sticky;
    bottom: -1rem;
    z-index: 2;
    width: 100%;
    min-height: 48px;
    margin-top: 1rem;
    border: 1px solid #77d6ff;
    background: #12364a;
    color: #eaf6ff;
    font: 600 .9rem/1.3 system-ui, sans-serif;
    touch-action: manipulation;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ashfall-difficulty,
  .ashfall-commander-card,
  .ashfall-extension,
  .ashfall-toggle,
  .ashfall-mut { transition: none; }
}
