/* ==========================================================
   MINECO STUDIOS — MOBILE / TOUCH OPTIMISATION
   Loaded by config.js after the page-specific styles so this
   layer can keep every public page consistent on phones/tablets.
========================================================== */

@media (max-width: 900px) {
  :root {
    --mineco-mobile-nav-height: 108px;
  }

  html {
    scroll-padding-top: calc(var(--mineco-mobile-nav-height) + 16px);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

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

  /* -------------------------------------------------------
     Shared mobile navigation
  ------------------------------------------------------- */

  nav {
    height: auto !important;
    min-height: var(--mineco-mobile-nav-height) !important;
    padding: env(safe-area-inset-top) 0 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    background: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
  }

  nav .brand {
    flex: 0 0 54px;
    min-height: 54px;
    width: 100%;
    padding: 0 16px;
    gap: 10px;
    font-size: 1rem !important;
  }

  nav .brand span {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  nav .logo {
    width: 34px !important;
    height: auto;
  }

  nav .links {
    display: flex !important;
    width: 100%;
    min-width: 0;
    gap: 4px !important;
    padding: 0 10px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  nav .links::-webkit-scrollbar {
    display: none;
  }

  nav .links a {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: max-content;
    min-height: 44px;
    padding-inline: 12px !important;
    color: #e8ecec;
    font-size: 0.86rem !important;
    line-height: 1;
    white-space: nowrap;
    scroll-snap-align: center;
    touch-action: manipulation;
  }

  .announcement-banner {
    top: calc(var(--mineco-mobile-nav-height) + env(safe-area-inset-top)) !important;
    padding: 9px 14px;
    font-size: 0.82rem;
  }

  /* -------------------------------------------------------
     Shared typography / controls
  ------------------------------------------------------- */

  h1,
  h2,
  h3,
  p,
  label,
  span,
  a,
  button {
    overflow-wrap: break-word;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
    font-size: 16px !important;
  }

  input,
  select,
  textarea {
    min-height: 48px;
  }

  textarea {
    min-height: 130px;
  }

  button,
  .button,
  [role="button"],
  .server-action,
  .contact-method-link,
  .socials a,
  .creator-social-links a {
    touch-action: manipulation;
  }

  .button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 20px !important;
    border-radius: 11px;
  }

  /* -------------------------------------------------------
     Home / generic hero pages
  ------------------------------------------------------- */

  .hero {
    min-height: 100svh !important;
    padding: calc(var(--mineco-mobile-nav-height) + 28px) 16px 42px !important;
  }

  .home-hero {
    min-height: 100svh !important;
    padding: calc(var(--mineco-mobile-nav-height) + 26px) 18px 52px !important;
  }

  .home-hero .heroLogo {
    width: clamp(155px, 48vw, 220px) !important;
    margin-bottom: 20px !important;
  }

  .heroLogo {
    width: min(220px, 58vw) !important;
    height: auto;
  }

  .hero h1,
  .home-hero h1 {
    max-width: 100%;
    font-size: clamp(1.9rem, 8.5vw, 3rem) !important;
    line-height: 1.08 !important;
  }

  .hero p,
  .home-hero p {
    max-width: 650px;
    font-size: 0.96rem !important;
    line-height: 1.65 !important;
  }

  .buttons,
  .home-actions {
    width: 100%;
    gap: 10px !important;
  }

  .buttons .button,
  .home-actions .button {
    width: min(100%, 360px) !important;
  }

  .features-section {
    width: min(100% - 24px, 1120px) !important;
    padding: 46px 0 60px !important;
  }

  .section-heading {
    margin-bottom: 24px !important;
  }

  .features-section h2 {
    font-size: clamp(1.75rem, 8vw, 2.45rem) !important;
  }

  .feature-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .feature-card {
    min-height: 0 !important;
    padding: 22px !important;
    border-radius: 14px !important;
  }

  /* -------------------------------------------------------
     Creators
  ------------------------------------------------------- */

  .creatorHero {
    padding: calc(var(--mineco-mobile-nav-height) + 28px) 16px 34px !important;
  }

  .creatorHero h1 {
    font-size: clamp(2rem, 10vw, 3.1rem) !important;
  }

  .creatorHero > .heroContent > p:last-child {
    font-size: 0.94rem !important;
    line-height: 1.6 !important;
  }

  .creators-list-section,
  .join-creators-section {
    width: min(100% - 24px, 1120px) !important;
  }

  .creators-list-section {
    padding: 4px 0 56px !important;
  }

  .creatorGrid {
    grid-template-columns: minmax(0, 1fr) !important;
    justify-content: stretch !important;
    gap: 14px !important;
  }

  .creatorCard {
    width: 100%;
    min-height: 0 !important;
    border-radius: 16px !important;
  }

  .card-image {
    padding: 26px 18px 14px !important;
  }

  .creator-avatar {
    width: 108px !important;
    height: 108px !important;
  }

  .card-content {
    height: auto !important;
    padding: 0 20px 24px !important;
  }

  .creatorCard h2 {
    font-size: 1.45rem !important;
  }

  .role {
    max-width: 100%;
    min-height: 30px !important;
    padding: 7px 10px !important;
    justify-content: center;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
  }

  .creatorCard .creator-bio {
    flex: initial !important;
    margin-bottom: 20px !important;
  }

  .socials {
    gap: 8px !important;
  }

  .socials a {
    width: 44px !important;
    height: 44px !important;
  }

  .join-creators-section {
    padding-bottom: 62px !important;
  }

  .join-creators-panel {
    padding: 34px 18px !important;
    border-radius: 16px !important;
  }

  .join-creators-panel h2 {
    font-size: clamp(1.8rem, 8.5vw, 2.5rem) !important;
  }

  .join-actions {
    width: 100%;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .join-actions .button {
    width: 100% !important;
  }

  /* -------------------------------------------------------
     Servers
  ------------------------------------------------------- */

  .servers-hero {
    padding: calc(var(--mineco-mobile-nav-height) + 30px) 16px 36px !important;
  }

  .servers-hero h1 {
    font-size: clamp(2rem, 10vw, 3.1rem) !important;
  }

  .servers-hero p:last-child {
    font-size: 0.94rem !important;
    line-height: 1.6 !important;
  }

  .servers-section {
    width: min(100% - 24px, 1240px) !important;
    padding: 4px 0 60px !important;
  }

  .servers-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  .server-card {
    min-height: 0 !important;
    border-radius: 16px !important;
  }

  .server-art {
    min-height: 118px !important;
  }

  .server-art img {
    height: auto !important;
    min-height: 140px;
    max-height: 210px;
    object-fit: cover;
  }

  .server-card-body {
    padding: 19px !important;
  }

  .server-card-topline {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 9px !important;
  }

  .server-card h2 {
    font-size: 1.4rem !important;
  }

  .server-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .server-meta-item {
    min-width: 0;
    padding: 10px !important;
  }

  .server-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .server-action {
    width: 100% !important;
    min-height: 46px !important;
  }

  /* -------------------------------------------------------
     Live & Latest
  ------------------------------------------------------- */

  .live-main {
    width: min(100% - 24px, 1220px) !important;
    padding: calc(var(--mineco-mobile-nav-height) + 18px) 0 58px !important;
  }

  .live-hero {
    padding: 18px 6px 34px !important;
    gap: 10px !important;
  }

  .live-hero h1 {
    font-size: clamp(2rem, 11vw, 3.2rem) !important;
    line-height: 1.02 !important;
  }

  .live-intro {
    font-size: 0.94rem !important;
    line-height: 1.6 !important;
  }

  .live-feed-meta {
    max-width: 100%;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 7px !important;
    border-radius: 12px !important;
    text-align: center;
  }

  .activity-section {
    margin-top: 18px !important;
    padding: 16px !important;
    border-radius: 15px !important;
  }

  .activity-heading {
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .activity-heading h2 {
    font-size: 1.3rem !important;
  }

  .live-grid,
  .latest-grid,
  .creator-channel-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .live-card,
  .content-card,
  .creator-channel-card {
    border-radius: 13px !important;
  }

  .media-body {
    padding: 13px !important;
  }

  .media-title {
    min-height: auto !important;
    font-size: 0.94rem !important;
  }

  .creator-social-links a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 7px 10px !important;
  }

  /* -------------------------------------------------------
     Apply
  ------------------------------------------------------- */

  .apply-hero {
    padding: calc(var(--mineco-mobile-nav-height) + 24px) 14px 28px !important;
  }

  .apply-mark {
    width: 66px !important;
    height: 66px !important;
    margin-bottom: 12px !important;
  }

  .apply-hero h1 {
    font-size: clamp(2rem, 10vw, 3.15rem) !important;
  }

  .apply-intro {
    margin-top: 14px !important;
    font-size: 0.94rem !important;
    line-height: 1.6 !important;
  }

  .apply-process {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 7px !important;
    margin-top: 24px !important;
    padding: 10px !important;
  }

  .apply-process > i {
    display: none !important;
  }

  .apply-process > div {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto !important;
    justify-items: center;
    gap: 4px !important;
    min-width: 0;
    text-align: center !important;
  }

  .apply-process span {
    grid-row: auto !important;
    width: 30px !important;
    height: 30px !important;
  }

  .apply-process strong {
    font-size: 0.78rem !important;
  }

  .apply-process small {
    display: none;
  }

  .application-wrap {
    width: min(100% - 24px, 1180px) !important;
    margin-bottom: 54px !important;
  }

  .application-heading {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .application-note {
    max-width: none !important;
    width: 100%;
  }

  #application-form {
    gap: 12px !important;
  }

  .form-section {
    padding: 16px !important;
    border-radius: 12px !important;
  }

  .form-section-heading {
    align-items: flex-start !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
    padding-bottom: 13px !important;
  }

  .form-grid.two-col,
  .form-grid.three-col {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .form-grid {
    gap: 14px !important;
  }

  .form-group input,
  .form-group select,
  .form-group textarea,
  #profile_color_hex,
  .discord-verify-input {
    font-size: 16px !important;
  }

  .profile-colour-picker {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  .profile-colour-preview {
    min-height: 82px !important;
    padding: 14px !important;
  }

  .colour-input-row {
    grid-template-columns: 52px minmax(0, 1fr) 26px !important;
  }

  #profile_color {
    width: 52px !important;
    height: 48px !important;
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .choice-chip span {
    min-height: 48px !important;
    padding: 9px 8px !important;
  }

  .discord-link-card,
  .discord-verify-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 13px !important;
  }

  .discord-verify-controls,
  .discord-verify-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr !important;
    justify-content: stretch !important;
  }

  .discord-verify-input,
  .discord-connect-button,
  .discord-change-button {
    width: 100% !important;
    min-height: 48px !important;
  }

  .submit-area {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
    padding: 16px !important;
  }

  #submit-button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 50px;
  }

  .success-container {
    width: 100%;
    padding: 24px 16px !important;
  }

  /* -------------------------------------------------------
     Contact
  ------------------------------------------------------- */

  .contact-main {
    width: min(100% - 24px, 1120px) !important;
    padding: calc(var(--mineco-mobile-nav-height) + 16px) 0 56px !important;
  }

  .contact-hero {
    padding: 16px 6px 28px !important;
  }

  .contact-hero h1 {
    font-size: clamp(2rem, 10vw, 3.1rem) !important;
  }

  .contact-intro {
    font-size: 0.94rem !important;
  }

  .contact-layout,
  .contact-layout.methods-hidden {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  .contact-panel {
    border-radius: 15px !important;
  }

  .contact-panel-header,
  .contact-methods-body,
  .contact-form-body,
  .creator-application-panel {
    padding: 16px !important;
  }

  .contact-methods-grid,
  .contact-form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .contact-method-link {
    min-height: 48px !important;
  }

  .contact-form-grid input,
  .contact-form-grid select,
  .contact-form-grid textarea {
    font-size: 16px !important;
  }

  .contact-submit-row {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  .contact-submit-row .button {
    width: 100% !important;
  }

  .creator-application-panel {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  .creator-application-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .creator-application-actions .button {
    width: 100% !important;
  }

  /* -------------------------------------------------------
     Application status
  ------------------------------------------------------- */

  #status-check-container {
    width: 100% !important;
    max-width: 600px;
    margin: 24px auto 0 !important;
    padding: 18px !important;
    border-width: 1px !important;
  }

  #status-check-container .input-with-button {
    flex-direction: column !important;
    gap: 8px !important;
  }

  #status-check-container .toggle-button,
  #check-status-button {
    width: 100% !important;
    min-height: 48px;
  }

  .status-result-container h2 {
    font-size: 1.45rem !important;
  }

  .detail-item {
    padding: 13px !important;
  }

  /* -------------------------------------------------------
     Leave MineCo Studios
  ------------------------------------------------------- */

  .leave-page {
    min-height: 100svh !important;
    padding: calc(var(--mineco-mobile-nav-height) + 24px) 12px 58px !important;
  }

  .leave-card {
    width: 100% !important;
    padding: 16px !important;
    border-radius: 15px !important;
  }

  .leave-heading h1 {
    font-size: clamp(1.8rem, 9vw, 2.45rem);
  }

  .leave-section {
    padding: 15px !important;
  }

  .verify-controls {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .verify-controls input,
  #leaveReason,
  .code-input {
    font-size: 16px !important;
  }

  .leave-primary-btn,
  .leave-danger-btn,
  .leave-secondary-btn {
    width: 100% !important;
    min-height: 48px !important;
  }

  /* -------------------------------------------------------
     News / legacy Join pages
  ------------------------------------------------------- */

  .news-detail {
    width: min(100% - 24px, 1000px) !important;
    padding: calc(var(--mineco-mobile-nav-height) + 22px) 0 54px !important;
  }

  .news-content-container {
    padding: 20px 16px !important;
    border-radius: 16px !important;
  }

  .news-hero-image {
    height: auto !important;
    max-height: 340px;
    aspect-ratio: 16 / 9;
  }

  .news-title {
    font-size: clamp(1.65rem, 8vw, 2.2rem) !important;
  }

  .news-body {
    font-size: 1rem !important;
    line-height: 1.7 !important;
  }

  .news-body pre,
  .news-body table {
    max-width: 100%;
    overflow-x: auto;
  }

  #creators > img[style] {
    width: 100% !important;
    max-width: 420px !important;
    height: auto !important;
  }

  /* -------------------------------------------------------
     Footer / safe-area
  ------------------------------------------------------- */

  footer {
    padding: 26px 16px calc(26px + env(safe-area-inset-bottom)) !important;
    font-size: 0.86rem;
  }
}

@media (max-width: 520px) {
  :root {
    --mineco-mobile-nav-height: 104px;
  }

  nav .brand {
    flex-basis: 50px;
    min-height: 50px;
    padding-inline: 13px;
  }

  nav .brand span {
    font-size: 0.94rem !important;
  }

  nav .logo {
    width: 31px !important;
  }

  nav .links {
    padding-inline: 7px;
  }

  nav .links a {
    min-height: 44px;
    padding-inline: 10px !important;
    font-size: 0.82rem !important;
  }

  .hero h1,
  .home-hero h1,
  .creatorHero h1,
  .servers-hero h1,
  .live-hero h1,
  .apply-hero h1,
  .contact-hero h1 {
    letter-spacing: -0.02em;
  }

  .home-hero .heroLogo {
    width: 160px !important;
  }

  .feature-card,
  .creatorCard,
  .server-card,
  .activity-section,
  .form-section,
  .contact-panel,
  .leave-card {
    box-shadow: none !important;
  }

  .server-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .activity-heading {
    flex-direction: row !important;
  }

  .activity-count {
    font-size: 0.68rem !important;
  }

  .media-meta-row {
    align-items: flex-end !important;
  }

  .choice-grid {
    grid-template-columns: 1fr !important;
  }

  .colour-input-row {
    grid-template-columns: 50px minmax(0, 1fr) 24px !important;
  }

  .application-heading h2 {
    font-size: 1.55rem !important;
  }

  .contact-panel h2 {
    font-size: 1.22rem !important;
  }

  .leave-section-title > div {
    align-items: flex-start !important;
  }

  .news-body blockquote {
    margin-inline: 0 !important;
    padding: 10px 14px !important;
  }
}

/* Touch devices should not retain desktop hover transforms after a tap. */
@media (hover: none), (pointer: coarse) {
  .logo:hover,
  .button:hover,
  .button-primary:hover,
  .feature-card:hover,
  .creatorCard:hover,
  .socials a:hover,
  .server-card:hover,
  .server-action:hover,
  .live-card:hover,
  .content-card:hover,
  .contact-method-link:hover,
  .choice-chip:hover span,
  .news-card:hover,
  .read-more:hover {
    transform: none !important;
  }

  .button,
  button,
  a,
  label {
    -webkit-tap-highlight-color: rgba(3, 252, 240, 0.12);
  }
}

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

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