/* The frame of every dialog, also loaded alone by pages without the portal
   theme (the Mravenci homepage). */
@import "./dialog.css";

:root {
  --portal-bg: #fcfaff;
  --portal-surface: #f6f3fb;
  --portal-surface-raised: #ede7f6;
  --portal-text: #211a2e;
  --portal-text-muted: #6d627c;
  --portal-border: #dfd7eb;
  --portal-control-border: #897699;
  --portal-focus: #7c3aed;
  --portal-accent-text: #7c3aed;
  --portal-primary: #7c3aed;
  --portal-primary-text: #ffffff;
  --portal-danger: #b42318;
  --portal-radius-control: 0.5rem;
  --portal-radius-panel: 0.75rem;
  --portal-shadow-overlay: 0 24px 80px rgb(0 0 0 / 0.28);
  --portal-font-sans:
    Geist, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --portal-font-mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --portal-layer-overlay: 1000;
  --portal-layer-popover: 1100;
}

@media (prefers-color-scheme: dark) {
  :root {
    --portal-bg: #100c18;
    --portal-surface: #191321;
    --portal-surface-raised: #251b32;
    --portal-text: #f4effa;
    --portal-text-muted: #b3a6c6;
    --portal-border: #382945;
    --portal-control-border: #806995;
    --portal-focus: #c4b5fd;
    --portal-accent-text: #c4b5fd;
    --portal-primary: #a78bfa;
    --portal-primary-text: #170d2b;
    --portal-danger: #f97066;
  }
}

html[data-portal-theme="light"] {
  --portal-bg: #fcfaff;
  --portal-surface: #f6f3fb;
  --portal-surface-raised: #ede7f6;
  --portal-text: #211a2e;
  --portal-text-muted: #6d627c;
  --portal-border: #dfd7eb;
  --portal-control-border: #897699;
  --portal-focus: #7c3aed;
  --portal-accent-text: #7c3aed;
  --portal-primary: #7c3aed;
  --portal-primary-text: #ffffff;
  --portal-danger: #b42318;
}

html[data-portal-theme="dark"] {
  --portal-bg: #100c18;
  --portal-surface: #191321;
  --portal-surface-raised: #251b32;
  --portal-text: #f4effa;
  --portal-text-muted: #b3a6c6;
  --portal-border: #382945;
  --portal-control-border: #806995;
  --portal-focus: #c4b5fd;
  --portal-accent-text: #c4b5fd;
  --portal-primary: #a78bfa;
  --portal-primary-text: #170d2b;
  --portal-danger: #f97066;
}

.portal-surface,
.portal-dialog-content,
.portal-popover-content {
  color-scheme: light dark;
  color: var(--portal-text);
  font-family: var(--portal-font-sans);
}

html[data-portal-theme="light"]
  :is(.portal-surface, .portal-dialog-content, .portal-popover-content) {
  color-scheme: light;
}
html[data-portal-theme="dark"]
  :is(.portal-surface, .portal-dialog-content, .portal-popover-content) {
  color-scheme: dark;
}
/* A running game lends its palette (useGamePalette); it beats the toggle. */
html[data-portal-palette="light"]
  :is(.portal-surface, .portal-dialog-content, .portal-popover-content) {
  color-scheme: light;
}
html[data-portal-palette="dark"]
  :is(.portal-surface, .portal-dialog-content, .portal-popover-content) {
  color-scheme: dark;
}

.portal-button,
.portal-theme-toggle {
  box-sizing: border-box;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--portal-radius-control);
  font: 500 0.9375rem/1 var(--portal-font-sans);
  cursor: pointer;
}

.portal-button {
  min-width: 44px;
  padding: 0.75rem 1rem;
}
.portal-button--primary {
  background: var(--portal-primary);
  color: var(--portal-primary-text);
}
.portal-button--secondary {
  border-color: var(--portal-control-border);
  background: transparent;
  color: var(--portal-text);
}
.portal-button--quiet {
  background: transparent;
  color: var(--portal-text);
}
.portal-button--destructive {
  background: var(--portal-danger);
  color: #fff;
}

.portal-button:focus-visible,
.portal-theme-toggle:focus-visible,
.portal-dialog-content:focus-visible,
.portal-popover-content:focus-visible {
  outline: 3px solid var(--portal-focus);
  outline-offset: 2px;
}

.portal-theme-toggle {
  display: inline-grid;
  flex: 0 0 44px;
  min-width: 44px;
  width: 44px;
  padding: 0;
  place-items: center;
  border-color: var(--portal-border);
  background: var(--portal-surface);
  color: var(--portal-text);
}
.portal-theme-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.portal-theme-toggle__sun {
  display: none;
}
html[data-portal-theme="dark"] .portal-theme-toggle__sun {
  display: initial;
}
html[data-portal-theme="dark"] .portal-theme-toggle__moon {
  display: none;
}

.portal-dialog-overlay {
  position: fixed;
  z-index: var(--portal-layer-overlay);
  inset: 0;
  background: rgb(0 0 0 / 0.66);
}

.portal-dialog-content {
  position: fixed;
  z-index: calc(var(--portal-layer-overlay) + 1);
  top: 50%;
  left: 50%;
  box-sizing: border-box;
  width: min(38rem, calc(100vw - 2rem));
  max-height: min(85dvh, 48rem);
  transform: translate(-50%, -50%);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-panel);
  background: var(--portal-surface);
  box-shadow: var(--portal-shadow-overlay);
}

.portal-dialog-content [data-radix-dialog-title] {
  margin: 0;
}

.portal-popover-content {
  z-index: var(--portal-layer-popover);
  box-sizing: border-box;
  width: min(20rem, calc(100vw - 2rem));
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-control);
  background: var(--portal-surface-raised);
  box-shadow: var(--portal-shadow-overlay);
  padding: 0.75rem;
}

@media (max-width: 36rem) {
  .portal-dialog-content {
    --portal-dialog-pad: 1rem;

    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .portal-dialog-overlay[data-state="open"] {
    animation: portal-fade-in 120ms ease-out;
  }
  .portal-dialog-content[data-state="open"],
  .portal-popover-content[data-state="open"] {
    animation: portal-enter 140ms ease-out;
  }
  @keyframes portal-fade-in {
    from {
      opacity: 0;
    }
  }
  @keyframes portal-enter {
    from {
      opacity: 0;
      translate: 0 6px;
    }
  }
}

/* Portal-wide: pointing at a link takes its underline away. */
a:hover,
a:focus-visible {
  text-decoration: none;
}

/* A picture inside a control is part of the control. Pressing it must not
   start a native image drag (the click is then lost) or the phone's
   save-image callout, so the press goes to the control itself. Controls
   also keep their labels unselectable: a quick double tap or a slight drag
   over a card or button selects nothing. */
:where(
    button,
    a,
    label,
    summary,
    [role="button"],
    [role="switch"],
    [role="option"],
    [role="tab"]
  )
  img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

:where(
  button,
  summary,
  [role="button"],
  [role="switch"],
  [role="option"],
  [role="tab"]
) {
  -webkit-user-select: none;
  user-select: none;
}

/* The same sweep as the Mravenci main action, available to any game. */
.portal-button--primary,
.portal-action-shine {
  position: relative;
  overflow: hidden;
}
.portal-button--primary:not(:disabled):not([aria-disabled="true"])::after,
.portal-action-shine:not(:disabled):not([aria-disabled="true"])::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgb(255 255 255 / 55%) 50%,
    transparent 70%
  );
  translate: -110% 0;
}
@media (prefers-reduced-motion: no-preference) {
  .portal-button--primary:not(:disabled):not([aria-disabled="true"])::after,
  .portal-action-shine:not(:disabled):not([aria-disabled="true"])::after {
    animation: portal-action-shine 3.2s cubic-bezier(0.5, 0, 0.3, 1) 0.8s
      infinite;
  }
}
@keyframes portal-action-shine {
  55%,
  100% {
    translate: 110% 0;
  }
}
