/*
 * DARKO v13.9 - mobile readability.
 * Load AFTER style.css and listings.css. Keep both original files unchanged.
 * No changes to authentication, contact permissions, APIs or stored data.
 * Desktop listings and pagination remain unchanged; no carousel in this release.
 */
@media (max-width: 850px) {
  html {
    scroll-padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
  }
  body {
    font-size: 1.0625rem;
    line-height: 1.55;
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }
  .wrap { padding-left: 18px; padding-right: 18px; }

  /* A tall header must not cover the page while reading on a phone.
     The existing bottom navigation remains fixed and always available. */
  .top { position: static; }
  .top .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    min-height: 0;
    align-items: center;
    gap: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .nav > nav { display: none; }
  .navright { display: contents; }
  .top .brand {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: -1px;
    padding-right: 64px;
  }
  .top .mark {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    margin-right: 9px;
    font-size: 27px;
    line-height: 1;
  }
  .navright .lang {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    min-width: 48px;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 1.0625rem;
    line-height: 1.3;
  }
  .navright .smallbtn {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 11px 12px;
    font-size: 1rem;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #login { grid-column: 1; grid-row: 2; }
  #registerBtn { grid-column: 2; grid-row: 2; }
  #darkoAccount {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    min-width: 0;
    font-size: 1.0625rem;
    line-height: 1.5;
  }
  #darkoAccountName {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  #darkoAccount button {
    min-width: 0;
    min-height: 48px;
    padding: 11px 12px;
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  /* Hidden elements must not reserve grid cells or expose account controls. */
  #darkoAccount[hidden], #login[hidden], #registerBtn[hidden] { display: none !important; }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 26px;
    padding-top: 28px;
    padding-bottom: 34px;
  }
  .hero-grid > div { min-width: 0; }
  .eyebrow { font-size: 1rem; line-height: 1.5; letter-spacing: .3px; }
  .pulse { flex: 0 0 9px; }
  .hero h1 {
    font-size: clamp(2.125rem, 8vw, 2.75rem);
    line-height: 1.15;
    letter-spacing: -1.5px;
    margin: 18px 0;
    overflow-wrap: anywhere;
  }
  .hero .lead {
    font-size: 1.125rem;
    line-height: 1.65;
    margin: 0;
    max-width: 38rem;
    color: #405e51;
  }
  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
  }
  .actions .btn {
    min-width: 0;
    width: 100%;
    min-height: 56px;
    padding: 15px 18px;
    font-size: 1.125rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .hero-note {
    font-size: 1rem;
    line-height: 1.6;
    margin-top: 16px;
    color: #4b6658;
  }

  /* These are the existing illustrative cards, not new interactive controls.
     Normal flow replaces the tiny, overlapping, absolutely positioned cards. */
  .hero-art {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    position: relative;
    height: auto;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    isolation: isolate;
  }
  .art-orb {
    width: 250px;
    height: 250px;
    max-width: 90%;
    left: 50%;
    top: 8%;
    transform: translateX(-50%);
    border-width: 20px;
    z-index: -1;
    pointer-events: none;
  }
  .hero-art .floatcard {
    position: relative;
    inset: auto;
    width: 100%;
    min-width: 0;
    min-height: 82px;
    transform: none;
    padding: 14px;
    gap: 12px;
    border-radius: 16px;
    box-shadow: 0 8px 24px #234d2e0d;
    border: 1px solid #e1eddf;
  }
  .hero-art .floatcard > span {
    display: grid;
    place-items: center;
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    font-size: 28px;
    line-height: 1;
    padding: 7px;
  }
  .hero-art .floatcard > div { min-width: 0; flex: 1 1 auto; }
  .hero-art .floatcard b {
    font-size: 1.125rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .hero-art .floatcard small {
    font-size: 1rem;
    line-height: 1.45;
    margin-top: 3px;
    color: #52695c;
    overflow-wrap: anywhere;
  }
  .hero-art .floatcard strong { font-size: 21px; flex: 0 0 auto; }
  .art-stamp { display: none; }

  .section-kicker { font-size: .9375rem; line-height: 1.55; letter-spacing: 1.5px; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .section-head > div { min-width: 0; }
  .section-head h2, .tribute h2, .how h2 { line-height: 1.25; overflow-wrap: anywhere; }
  .section-head .muted, .tribute p, .steps p { font-size: 1.0625rem; line-height: 1.65; }
  .textbtn, .section-head .btn {
    min-height: 48px;
    font-size: 1.0625rem;
    line-height: 1.45;
    white-space: normal;
  }
  .chips { gap: 10px; }
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    max-width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    line-height: 1.45;
    text-align: left;
  }
  .chip span { min-width: 0; overflow-wrap: anywhere; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .filters label, .field { min-width: 0; font-size: 1rem; line-height: 1.45; }
  .filters input, .filters select, .field input, .field select, .field textarea {
    font-size: 1.0625rem;
    line-height: 1.5;
    min-height: 48px;
    max-width: 100%;
  }
  .filters .reset { grid-column: 1 / -1; min-height: 48px; font-size: 1rem; }
  .cards, .worker-cards { grid-template-columns: minmax(0, 1fr); }
  .job-card, .worker-card { min-width: 0; }
  .job-card h3, .worker-card h3 { font-size: 1.375rem; line-height: 1.35; }
  .meta { font-size: 1rem; line-height: 1.5; }
  .meta span { max-width: 100%; overflow-wrap: anywhere; }
  .badge { font-size: .875rem; line-height: 1.4; }
  .price { font-size: 1.625rem; }
  .price small { font-size: 1rem; }
  .listing-actions button, .listing-status button, .more-button {
    min-height: 48px;
    font-size: 1rem;
    line-height: 1.45;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .listing-status, .listing-info { font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; }
  .result-count, .result-progress { font-size: 1rem; line-height: 1.5; }
  .empty { padding: 25px 18px; font-size: 1.0625rem; }

  .auth-dialog {
    width: min(480px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .auth-form { padding: 26px 22px; }
  .auth-form h2 { font-size: 1.75rem; line-height: 1.25; overflow-wrap: anywhere; }
  .auth-eyebrow { font-size: .875rem; line-height: 1.5; }
  .auth-intro { font-size: 1.0625rem; line-height: 1.6; }
  .auth-form label { font-size: 1rem; line-height: 1.5; margin: 12px 0 7px; }
  .auth-form input { min-height: 52px; font-size: 1.0625rem; line-height: 1.5; }
  .auth-submit, .auth-cancel { min-height: 48px; font-size: 1.0625rem; line-height: 1.5; }
  .auth-cancel { padding: 11px 16px; }
  #listingDetail, #modal {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 24px 20px;
  }
  .modal-head { gap: 10px; }
  .modal-head > div { min-width: 0; }
  .close {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    color: var(--ink);
    line-height: 1;
  }
  #listingDetail h2, #modal h2 { font-size: 1.75rem; line-height: 1.25; }
  #detailMeta, #detailDescription, #modalHelp { font-size: 1.0625rem; line-height: 1.65; }
  #listingDetail .detail-price { font-size: 1.75rem; }
  #modal .form-grid { grid-template-columns: minmax(0, 1fr); }
  #modal .form-grid .wide { grid-column: auto; }
  #modal .form-actions .btn, #detailCloseBottom, #contactReveal {
    min-height: 48px;
    font-size: 1.0625rem;
    line-height: 1.5;
    max-width: 100%;
    white-space: normal;
  }
  .contact-option, .contact-options p { font-size: 1rem; line-height: 1.6; }
  .contact-option { min-height: 48px; }
  .contact-options legend { font-size: 1.0625rem; }
  .contact-links { gap: 10px; }
  .contact-link {
    min-height: 48px;
    font-size: 1.0625rem;
    line-height: 1.45;
    flex: 1 1 125px;
    max-width: 100%;
    white-space: normal;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 15;
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 22px #153f300d;
    gap: 2px;
    padding: 7px 6px max(7px, env(safe-area-inset-bottom, 0px));
  }
  .bottom-nav a, .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 60px;
    max-width: 100%;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: #285e48;
    font-weight: 800;
  }
  .bottom-nav span { font-size: 28px; line-height: 1; }
  .bottom-nav small { font-size: .9375rem; line-height: 1.3; overflow-wrap: anywhere; max-width: 100%; }
  .bottom-nav button { color: #176f50; }
  #toast { bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); font-size: 1rem; line-height: 1.5; }
  section { scroll-margin-top: 20px; }
  .foot { flex-wrap: wrap; font-size: .9375rem; line-height: 1.6; }
  .foot > span { overflow-wrap: anywhere; }

  .navright button:focus-visible, .actions .btn:focus-visible,
  .chip:focus-visible, .bottom-nav a:focus-visible,
  .bottom-nav button:focus-visible, .close:focus-visible,
  .auth-submit:focus-visible, .auth-cancel:focus-visible {
    outline: 3px solid #156d50;
    outline-offset: 3px;
  }
}
@media (max-width: 600px) {
  #darkoAccount { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #darkoAccountName { grid-column: 1 / -1; }
  #darkoAccount button { width: 100%; }
}
@media (max-width: 480px) {
  .actions { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 360px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .auth-form { padding-left: 18px; padding-right: 18px; }
  #listingDetail, #modal { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
}
