/* EduRealm v31 - shared responsive safety layer for the public site and panels. */

:root {
  --er-page-gutter: clamp(14px, 3vw, 42px);
  --er-touch-target: 44px;
}

html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 0;
  max-width: 100%;
}

img,
picture,
video,
canvas,
svg,
iframe {
  max-width: 100%;
}

img,
picture,
video,
canvas {
  height: auto;
}

button,
input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
}

textarea {
  resize: vertical;
}

pre,
code,
.v18-secret,
.edu-secret {
  overflow-wrap: anywhere;
  word-break: break-word;
}

table {
  max-width: 100%;
}

.wrap,
.header-content,
.footer-content,
.contact-page,
.v18-control,
.bot-dashboard {
  padding-left: max(var(--er-page-gutter), env(safe-area-inset-left));
  padding-right: max(var(--er-page-gutter), env(safe-area-inset-right));
}

.table-wrap,
.v18-table-wrap,
.admin-table-wrap,
.bot-table-wrap,
.forum-table-wrap,
[data-table-scroll] {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table,
.v18-table-wrap table,
.admin-table-wrap table,
.bot-table-wrap table,
.forum-table-wrap table,
[data-table-scroll] table {
  min-width: 680px;
}

input[type="color"] {
  min-height: 44px;
  padding: 4px;
  overflow: hidden;
  border-radius: 12px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 8px;
}

input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 8px;
}

.modal,
.dialog,
.drawer,
.sheet,
.v18-modal,
.bot-modal,
.admin-modal,
.contact-chat-modal,
[role="dialog"] {
  overscroll-behavior: contain;
}

/* Large monitors and televisions: keep content readable instead of stretching it endlessly. */
@media (min-width: 1800px) {
  html {
    font-size: clamp(17px, .25vw + 12px, 20px);
  }

  .wrap,
  .header-content,
  .footer-content,
  .contact-page {
    width: min(1680px, calc(100% - 80px));
    margin-inline: auto;
  }

  .v18-control,
  .bot-dashboard {
    width: min(1840px, 100%);
    margin-inline: auto;
  }

  .section-title,
  .page-hero h1 {
    max-width: 22ch;
  }
}

@media (min-width: 2400px) {
  html {
    font-size: 20px;
  }

  .wrap,
  .header-content,
  .footer-content,
  .contact-page {
    width: min(1920px, calc(100% - 120px));
  }

  .v18-control,
  .bot-dashboard {
    width: min(2100px, 100%);
  }
}

/* Laptops and tablets. */
@media (max-width: 1100px) {
  .v18-control-header,
  .panel-header,
  .admin-section-head,
  .bot-section-head,
  .card-head,
  .toolbar,
  .action-row {
    flex-wrap: wrap;
    gap: 12px;
  }

  .v18-grid-3,
  .v18-module-grid,
  .dashboard-grid,
  .admin-dashboard-grid,
  .bot-dashboard-grid,
  .pricing-admin-grid,
  .commerce-admin-grid,
  .resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .contact-layout,
  .designer-layout,
  .panel-split,
  .admin-split,
  .bot-split {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 900px) {
  .site-header .nav {
    height: auto;
    min-height: 72px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* Panel pages do not have a hamburger; their navigation stays usable as a swipeable row. */
  .site-header .nav > .brand + .nav-links {
    position: static;
    display: flex;
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    width: 100%;
    max-height: none;
    margin: 2px 0 0;
    padding: 6px 0;
    overflow-x: auto;
    gap: 8px;
    border: 0;
    background: transparent;
    box-shadow: none;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .site-header .nav > .brand + .nav-links::-webkit-scrollbar {
    display: none;
  }

  .site-header .nav > .brand + .nav-links a,
  .site-header .nav > .brand + .nav-links button {
    flex: 0 0 auto;
    min-height: var(--er-touch-target);
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .footer-grid,
  .footer-content,
  .discord-content {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .footer-content,
  .discord-content {
    gap: 28px;
  }
}

/* Phones and narrow tablets. */
@media (max-width: 760px) {
  :root {
    --er-page-gutter: 14px;
    --er-touch-target: 48px;
  }

  .wrap,
  .header-content,
  .footer-content,
  .contact-page,
  .v18-control,
  .bot-dashboard {
    width: 100%;
  }

  .page-hero,
  .section-dark,
  .panel-section,
  .account-section,
  .forum-page-section {
    overflow-x: clip;
  }

  .page-hero h1,
  .section-title,
  .contact-heading h1,
  .legal-document h1 {
    font-size: clamp(2rem, 10vw, 3.25rem) !important;
    line-height: 1.02;
    overflow-wrap: anywhere;
  }

  .lead,
  .legal-lead,
  .contact-heading p {
    font-size: 1rem !important;
  }

  .v18-grid-2,
  .v18-grid-3,
  .v18-module-grid,
  .v18-launcher-texts,
  .v26-metrics,
  .dashboard-grid,
  .admin-dashboard-grid,
  .bot-dashboard-grid,
  .bot-grid,
  .bot-form-grid,
  .pricing-grid,
  .pricing-admin-grid,
  .commerce-admin-grid,
  .resource-grid,
  .role-grid,
  .stats,
  .metrics,
  .card-grid,
  .form-grid,
  .form-row,
  .designer-settings,
  .rank-preview-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .v18-card,
  .panel-card,
  .admin-card,
  .bot-card,
  .contact-form-wrap,
  .contact-aside,
  .legal-summary {
    min-width: 0;
    padding: clamp(16px, 4vw, 24px) !important;
    border-radius: 20px !important;
  }

  .v18-control-header,
  .panel-header,
  .admin-section-head,
  .bot-section-head,
  .card-head,
  .toolbar,
  .action-row,
  .button-row,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .v18-control-header > *,
  .panel-header > *,
  .admin-section-head > *,
  .bot-section-head > *,
  .toolbar > *,
  .action-row > *,
  .button-row > *,
  .form-actions > * {
    max-width: 100%;
  }

  .v18-control-header button,
  .panel-header button,
  .admin-section-head button,
  .bot-section-head button,
  .button-row button,
  .form-actions button,
  .button-row .btn,
  .form-actions .btn {
    width: 100%;
    min-height: var(--er-touch-target);
  }

  .btn,
  button,
  [role="button"],
  input[type="submit"],
  input[type="button"] {
    min-height: var(--er-touch-target);
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .modal,
  .dialog,
  .v18-modal,
  .bot-modal,
  .admin-modal,
  [role="dialog"] {
    align-items: flex-end;
    padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .modal-content,
  .dialog-content,
  .v18-modal-card,
  .bot-modal-card,
  .admin-modal-card,
  [role="dialog"] > div {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    border-radius: 24px 24px 12px 12px !important;
  }

  .footer-bottom,
  .edurealm-footer-copy {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    text-align: center;
  }

  .footer-links {
    display: grid;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  :root {
    --er-page-gutter: 12px;
  }

  .brand,
  .logo {
    min-width: 0;
  }

  .brand span,
  .brand-word {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-header .nav > .brand + .nav-links a,
  .site-header .nav > .brand + .nav-links button {
    padding-inline: 12px;
    font-size: .86rem;
  }

  .v18-card,
  .panel-card,
  .admin-card,
  .bot-card {
    border-radius: 17px !important;
  }

  .toast,
  .notice-toast,
  .v18-toast,
  .bot-toast {
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    width: auto !important;
    max-width: none !important;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .site-header {
    position: relative;
  }

  .page-hero {
    min-height: auto !important;
    padding-top: 38px !important;
    padding-bottom: 38px !important;
  }

  .modal-content,
  .dialog-content,
  .v18-modal-card,
  .bot-modal-card,
  .admin-modal-card {
    max-height: calc(100dvh - 12px) !important;
  }
}

@media (pointer: coarse) {
  button,
  .btn,
  [role="button"],
  a.nav-link,
  .nav-links a {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
