/* Layout for the surfaces peakcord-compat.js builds.
 *
 * Flashcord already styles these — that is the entire point of building them —
 * so this file carries only what Beta assumed the client provided and therefore
 * never wrote itself: the box each row sits in. Anything that decides how a
 * swatch or a card *looks* belongs to flashcord.css and is deliberately absent
 * here.
 */

/* --- Appearance: the Flashcord theme picker ------------------------------ */

#peakcord-appearance {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 0 24px;
}

/* Beta sizes each swatch (`display:block; width:100%; height:24vh`) but never
   the row, because 2024's Appearance page supplied the grid. */
#peakcord-appearance [class^="basicThemeSelectors_"],
#peakcord-appearance [class^="advancedThemeSelectors_"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* Beta positions the hover caption with `position: absolute; bottom: 1rem`,
   which needs a positioned ancestor or every caption stacks on the viewport. */
#peakcord-appearance [class^="themeSelectionContainer_"] {
  position: relative;
}

/* Beta gives the CONTAINER a height (24vh) and the swatch inside it nothing,
   because 2024's client sized the swatch itself from
   `--custom-theme-selection-size`. Without that the swatch collapses to the
   height of its ::before text and every preview renders as a letterbox strip. */
#peakcord-appearance [class^="themeSelection_"] {
  cursor: pointer;
  position: relative;
  overflow: hidden;
  height: 100%;
  border-radius: var(--Flashcord-Border_Radius, 25px);
}

/* The advanced swatches carry no preview image of their own — Beta paints the
   two Iridescent ones and dims the rest — so give them the gradient the client
   used to supply, keyed off the same variable Beta selects on. */
#peakcord-appearance [style*="--bg-gradient-mint-apple"] { background: linear-gradient(135deg, #a8e063, #f6ffde); }
#peakcord-appearance [style*="--bg-gradient-sunset"] { background: linear-gradient(135deg, #2b1055, #7597de); }
#peakcord-appearance [style*="--bg-gradient-citrus-sherbert"] { background: linear-gradient(135deg, #ffd86f, #fc6262); }
#peakcord-appearance [style*="--bg-gradient-chroma-glow"] { background: linear-gradient(135deg, #6a3093, #a044ff); }
#peakcord-appearance [style*="--bg-gradient-sepia"] { background: linear-gradient(135deg, #6b5b45, #d9c7a7); }
#peakcord-appearance [style*="--bg-gradient-aurora"] { background: linear-gradient(135deg, #00311f, #14ff9b); }

/* The selected swatch has no other affordance: Beta hides the client's
   checkmark SVG, and our swatches never had one. */
#peakcord-appearance [aria-checked="true"] {
  outline: 3px solid var(--text-normal, #fff);
  outline-offset: 3px;
}

#peakcord-theme-reset {
  align-self: flex-start;
  padding: 8px 16px;
  border: none;
  border-radius: var(--Flashcord-Border_Radius, 25px);
  background: var(--background-secondary, #2b2d31);
  color: var(--text-normal, #fff);
  font-weight: 600;
  cursor: pointer;
}

/* --- Addons: the Replugged plugin list ----------------------------------- */

/* Beta's ~180 addon-card rules set `display: grid` on the card and paint a
   compatibility badge into ::before. The list around them was Replugged's. */
#rp-plugins-tab {
  padding-bottom: 24px;
}

#rp-plugins-tab .replugged-addon-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* `min-width: 0` because Beta sets `display: grid` on the card and its badge
   text is a long unbroken string; a grid item's default `min-width: auto`
   refuses to shrink below that, so the last column overflows the panel. */
#rp-plugins-tab .replugged-addon-card {
  min-width: 0;
  padding: 16px;
  border-radius: var(--Flashcord-Border_Radius, 25px);
  background: var(--background-secondary, #2b2d31);
  color: var(--text-normal, #fff);
  gap: 4px;
  align-content: start;
}

#rp-plugins-tab .replugged-addon-card h3 { margin: 0; font-size: 1.05rem; }
#rp-plugins-tab .replugged-addon-card a { color: inherit; text-decoration: none; }
#rp-plugins-tab .peakcord-addon-author { opacity: 0.65; font-size: 0.85rem; }
#rp-plugins-tab .peakcord-addon-desc { font-size: 0.9rem; line-height: 1.45; }

/* --- Correcting Beta's own copy ------------------------------------------
 *
 * Every user-facing string in Flashcord is a CSS variable with a default, so
 * the honest fix for text that is now wrong is to set the variable — not to
 * override the rule that prints it.
 */

/* Beta reports which client is running from `--FlashCore-Client`, detected by
   sniffing for Vencord or Replugged markers. Neither is here; say so plainly
   rather than leaving its About panel printing "404". */
html { --FlashCore-Client: "⚡ Peakcord"; }

/* The Advanced Themes notice tells the user ThemeHooker is missing and that
   Nitro is required. On Peakcord neither is true: peakcord-compat.js writes
   html[theme-hooker] itself, and there is no Nitro to gate anything behind. */
html {
  --FlashLang-C_AT-NoThemeHooker: "✅ ThemeHooker is built into Peakcord — every advanced theme is available, no Nitro and no Replugged.";
}

/* Beta dims Transparent and Terminal to `brightness(0.25)` and marks them
   not-allowed until ThemeHooker is detected, and only un-dims them inside
   @container FC-Theme_Hooker — which is itself only active once an advanced
   theme is already applied. That is unreachable by construction: the swatch
   that would turn the container on is the one being dimmed.
   Un-dimming ours directly avoids the alternative fix, which is forcing
   `container-type: inline-size` onto <html> permanently — that makes the root
   the containing block for every position:fixed popout in the client. */
#peakcord-appearance [class^="themeSelection_"] {
  filter: none !important;
  cursor: pointer !important;
}

/* --- Flashcord: the module control panel ---------------------------------
 *
 * Flashcord styles the addon list it expects Replugged to provide, but it has
 * never had a settings surface of its own to style — upstream's was a plugin
 * with its own UI. So unlike the theme picker above, this page needs real
 * layout rules. They are written against Discord's own variables so the page
 * follows both colour modes and every advanced theme.
 */

#rp-themes-tab {
  padding-bottom: 24px;
}

#peakcord-modules {
  display: flex;
  flex-direction: column;
  gap: 28px;
  color: var(--text-normal, #fff);
}

#peakcord-modules .pk-intro {
  font-size: 0.92rem;
  line-height: 1.55;
  opacity: 0.75;
  max-width: 62ch;
}

#peakcord-modules .pk-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#peakcord-modules .pk-section h2 {
  margin: 0 0 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.6;
}

#peakcord-modules .pk-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--Flashcord-Border_Radius, 25px);
  background: var(--background-modifier-hover, rgba(255, 255, 255, 0.04));
}

/* `min-width: 0` on the text column, not the row: the descriptions are long
   single strings and a flex item defaults to `min-width: auto`, which refuses
   to wrap and pushes every control off the right edge of the panel. */
#peakcord-modules .pk-row-text {
  flex: 1 1 auto;
  min-width: 0;
}

#peakcord-modules .pk-row-label {
  font-weight: 600;
  font-size: 0.95rem;
}

#peakcord-modules .pk-row-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  opacity: 0.62;
  margin-top: 2px;
}

#peakcord-modules .pk-row-control {
  flex: 0 0 auto;
}

#peakcord-modules .pk-select,
#peakcord-modules .pk-text {
  min-width: 190px;
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid var(--background-modifier-selected, rgba(255, 255, 255, 0.1));
  border-radius: calc(var(--Flashcord-Border_Radius, 25px) / 2);
  background: var(--background-floating, #1a1a1e);
  color: var(--text-normal, #fff);
  font: inherit;
  font-size: 0.85rem;
}

#peakcord-modules .pk-slider {
  display: flex;
  align-items: center;
  gap: 10px;
}

#peakcord-modules .pk-slider input {
  width: 150px;
  accent-color: var(--text-normal, #fff);
}

#peakcord-modules .pk-slider-value {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  opacity: 0.7;
}

#peakcord-modules-reset {
  align-self: flex-start;
  padding: 9px 18px;
  border: none;
  border-radius: var(--Flashcord-Border_Radius, 25px);
  background: var(--background-modifier-selected, #2b2d31);
  color: var(--text-normal, #fff);
  font-weight: 600;
  cursor: pointer;
}

/* Narrow panel — the settings window is 90vw under Flashcord's pop-up control
   panel, but the content column inside it is much narrower than the viewport.
   A container query on the page itself is the honest measure. */
@media (max-width: 1100px) {
  #peakcord-modules .pk-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #peakcord-modules .pk-row-control {
    align-self: flex-start;
  }
}

/* --- page scrolling ------------------------------------------------------
   Every page this layer builds is appended into `contentBody_`, which is
   `overflow: hidden`: Discord's own page is a child scroller, not the body
   itself. renderPage() copies that sibling's classes onto our host so it
   scrolls identically, but the sibling has not always rendered when a page is
   opened cold (deep-link into settings, or Flashcord's full-screen module
   swapping the layout out), and then there are no classes to copy. These rules
   make the host a scroller on its own account, so the page is never trapped. */
#rp-plugins-tab,
#rp-themes-tab,
#peakcord-admin-tab,
.pk-page {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  /* A flex child defaults to min-height:auto, which floors it at its content
     height — the parent then grows instead of the child scrolling. */
  min-height: 0;
  flex: 1 1 auto;
}

/* The page built inside a host must not scroll on its own account. Two nested
   scrollers means the outer one moves a few pixels, the inner one holds the
   content, and the wheel fights between them. */
#peakcord-modules,
#peakcord-admin,
.pk-page > * {
  overflow: visible;
  max-height: none;
  height: auto;
}

/* Discord's scroller classes carry the gutter; when we fall back to .pk-page
   alone there is none, and content sits under the scrollbar. */
.pk-page:not([class*="scrollbarGutter"]) {
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thin-thumb, #1a1b1e) transparent;
}
