/* Mobile UI port. Lives alongside theme.css.
   The visibility helpers are global; everything inside @media (max-width: 720px)
   only kicks in on phones. Resize the browser to see it switch. */

/* ---------- Visibility toggle (apply to top-level wrappers in each JSP) ---------- */
.gw-desktop-only { display: block; }
.gw-mobile-only  { display: none; }

@media (max-width: 720px) {

  .gw-desktop-only { display: none !important; }
  .gw-mobile-only  { display: block; }

  /* Reset the desktop body chrome — mobile has its own gradient header etc. */
  body {
    background: #c9d1dc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
  }

  :root {
    --gw-radius: 10px;
    --gw-radius-lg: 16px;
    --gw-shadow: 0 6px 18px rgba(15,40,80,.08);
    --gw-shadow-strong: 0 10px 30px rgba(15,40,80,.18);
    --gw-tap: 48px;
    --gw-bg-soft: #f3f5f8;
    --gw-bg-deep: #eaeef3;
    --gw-text-soft: #5e6975;
  }

  * { -webkit-tap-highlight-color: transparent; }

  /* ---------- Phone shell ---------- */
  .app {
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-bottom: 24px;
  }

  /* ---------- App-style top header ---------- */
  .app-header {
    background: linear-gradient(135deg, #004e7a 0%, #006298 100%);
    color: #fff;
    padding: 14px 16px 12px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .app-header .row {
    display: flex; align-items: center; gap: 10px; min-height: 32px;
  }
  .app-header h1 {
    font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; text-align: center;
  }
  .app-header .icon-btn {
    background: rgba(255,255,255,.12);
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    color: #fff; font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .app-header .icon-btn:active { background: rgba(255,255,255,.25); }
  .app-header .brand {
    display: flex; align-items: center; gap: 8px;
    font-size: .8rem; opacity: .9;
    margin-top: 6px;
  }
  .gw-mark {
    width: 22px; height: 22px; border-radius: 50%;
    background: conic-gradient(from 0deg,
      #e63946 0 60deg, #f4a261 60deg 120deg, #f5d04a 120deg 180deg,
      #2a9d8f 180deg 240deg, #ffffff 240deg 300deg, #6a4c93 300deg 360deg);
    position: relative; flex-shrink: 0;
  }
  .gw-mark::after { content: ""; position: absolute; inset: 5px; background: #fff; border-radius: 50%; }

  /* ---------- Body ---------- */
  .app-body { padding: 16px; flex: 1; }

  /* Reset typographic chrome on the .app frame */
  .app h1 { font-size: 1.15rem; }
  .app h2 { font-size: 1.05rem; margin: 18px 0 10px; color: #3a3838; }
  .app h2:first-child { margin-top: 4px; }
  /* Sub-heading inside a step (e.g. the DOT Service Location block). */
  .app h3 { font-size: .95rem; margin: 14px 0 8px; color: #3a3838; }
  .app p  { margin: 0 0 12px; }
  .app .text-soft { color: var(--gw-text-soft); font-size: .9rem; }
  .app .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
  .app a { color: #006298; text-decoration: none; }

  /* ---------- Cards ---------- */
  .app .card {
    background: #fff;
    border: 1px solid #e0e3e8;
    border-radius: var(--gw-radius-lg);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: var(--gw-shadow);
  }
  .app .card-tight { padding: 10px 14px; }
  .app .card-soft { background: var(--gw-bg-soft); box-shadow: none; }

  /* ---------- Hero CTA ---------- */
  .app .hero {
    background: linear-gradient(135deg, #006298, #0a2140);
    color: #fff;
    border-radius: var(--gw-radius-lg);
    padding: 18px;
    margin-bottom: 16px;
  }
  .app .hero h2 { color: #fff; margin: 0 0 6px; font-size: 1.2rem; }
  .app .hero p { font-size: .9rem; opacity: .95; margin: 0 0 14px; }
  .app .hero .btn { background: #fff; color: #3a3838; }

  /* ---------- Buttons ---------- */
  .app .btn {
    appearance: none; -webkit-appearance: none;
    background: #006298; color: #fff;
    font: inherit; font-weight: 600;
    border: none;
    border-radius: var(--gw-radius);
    padding: 0 18px;
    min-height: var(--gw-tap);
    display: inline-flex;
    align-items: center; justify-content: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    width: auto;
    transition: background .15s, transform .1s;
  }
  .app .btn:active { transform: scale(.98); }
  .app .btn-block { display: flex; width: 100%; }
  .app .btn-secondary { background: #fff; color: #004e7a; border: 1.5px solid #e0e3e8; }
  .app .btn-ghost { background: transparent; color: #006298; }
  .app .btn-success { background: #2e7d32; }
  .app .btn-lg { font-size: 1.05rem; min-height: 56px; }

  /* ---------- Form fields ---------- */
  .app .field { margin-bottom: 14px; }
  .app .field label, .app label.lbl {
    display: block; font-weight: 600; font-size: .9rem;
    margin-bottom: 6px; color: #1f1f1f;
  }
  .app .field .req { color: #b3261e; }
  .app .input, .app .select, .app .textarea {
    width: 100%; font: inherit;
    padding: 12px 14px;
    border: 1.5px solid #e0e3e8;
    border-radius: var(--gw-radius);
    background: #fff;
    color: #1f1f1f;
    min-height: var(--gw-tap);
  }
  .app .input:focus, .app .select:focus, .app .textarea:focus {
    outline: none; border-color: #006298;
    box-shadow: 0 0 0 3px rgba(0,98,152,.18);
  }
  .app .textarea { min-height: 90px; resize: vertical; }
  .app .help { font-size: .78rem; color: var(--gw-text-soft); margin-top: 4px; }

  /* ---------- Category chips ---------- */
  .app .chips {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  }
  .app .chip {
    appearance: none;
    border: 1.5px solid #e0e3e8;
    background: #fff;
    border-radius: var(--gw-radius);
    padding: 14px 10px;
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    cursor: pointer;
    font: inherit; font-weight: 600; font-size: .88rem;
    color: #1f1f1f;
    min-height: 88px;
    text-align: center;
    transition: border-color .15s, background .15s, transform .1s;
    text-decoration: none;
  }
  .app .chip .ic { font-size: 1.6rem; line-height: 1; }
  .app .chip:active { transform: scale(.97); }
  .app .chip.selected {
    border-color: #006298;
    background: #e3f0fa;
    color: #3a3838;
  }

  /* ---------- Department photo cards (county card component) ----------
     One per row rather than two: these carry the county's own department
     photos, and at half a phone's width the picture stops reading as a place
     and starts reading as texture. */
  /* margin-bottom matches the gap, so whatever follows the last card — the
     "Track your request" card on the landing page — is spaced from it the same
     way the cards are spaced from each other, instead of touching it. */
  .app .chips-photo { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
  .app .chip-photo {
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    text-align: left;
    gap: 0;
    min-height: 0;
  }
  .app .chip-photo .chip-figure {
    display: block;
    height: 130px;
    overflow: hidden;
    background: var(--gw-bg-deep);
  }
  .app .chip-photo .chip-figure img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
  }
  .app .chip-photo .chip-glyph {
    display: flex; align-items: center; justify-content: center;
    height: 100%; font-size: 2.6rem;
    background: linear-gradient(135deg, #006298, #0a2140);
  }
  .app .chip-photo .chip-body { padding: 12px 14px 14px; }
  .app .chip-photo .chip-title {
    display: block; font-size: 1rem; font-weight: 600; color: #3a3838;
  }
  .app .chip-photo .chip-desc {
    display: block; font-size: .82rem; font-weight: 400;
    color: var(--gw-text-soft); margin-top: 2px; line-height: 1.35;
  }
  .app .chip-photo.selected { background: #fff; border-color: #006298; border-width: 2px; }
  .app .chip-photo.selected .chip-body { background: #e3f0fa; }
  .app .chip-photo.selected .chip-title { color: #006298; }
  /* The landing cards are the only way into the form, and a photo with a
     caption reads as an illustration — this is the county's card button,
     same as the desktop tile, so the card is visibly pressable. */
  .app .chip-photo .chip-cta {
    /* Flex + min-height so it clears the 48px tap target this app uses, rather
       than whatever padding plus a line box happens to add up to. */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--gw-tap);
    margin: 0 14px 14px;
    padding: 10px 12px;
    background: #006298;
    border-radius: var(--gw-radius);
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-size: .92rem;
  }
  /* Tap feedback: the global -webkit-tap-highlight-color:transparent removes
     the browser's own flash, so the pressed state has to be drawn here. */
  .app .chip-photo:active { border-color: #006298; }
  .app .chip-photo:active .chip-cta { background: #004e7a; }

  /* ---------- Map ---------- */
  .app .map {
    /* Tall enough for the county-fit home view (same as the Parks page map). */
    width: 100%; height: 420px;
    border-radius: var(--gw-radius);
    overflow: hidden;
    border: 1px solid #e0e3e8;
    position: relative;
    /* Contain Leaflet's panes/controls so they don't cover the sticky .app-header. */
    z-index: 0;
  }
  .app .map-controls { display: flex; gap: 8px; margin-top: 8px; }
  .app .map-controls .btn { flex: 1; min-height: 44px; padding: 0 10px; font-size: .9rem; }

  /* ---------- Photo capture ---------- */
  .app .photos {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  }
  .app .photo-slot {
    position: relative;
    aspect-ratio: 1;
    border: 2px dashed #e0e3e8;
    border-radius: var(--gw-radius);
    background: var(--gw-bg-soft);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--gw-text-soft);
    cursor: pointer;
    font-size: .75rem;
    text-align: center;
    overflow: hidden;
  }
  .app .photo-slot .ic { font-size: 1.5rem; }
  .app .photo-slot input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
  }
  .app .photo-slot img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
  .app .photo-slot.filled { border-style: solid; border-color: #006298; padding: 0; }
  /* Held by the server after a rejected submission — the citizen keeps it
     without re-taking the picture. */
  .app .photo-slot.kept { border-color: #2e7d32; }
  .app .photo-slot .gw-photo-name {
    padding: 0 4px;
    font-size: .62rem;
    line-height: 1.15;
    word-break: break-all;
  }
  .app .photo-cell { display: flex; flex-direction: column; gap: 4px; }
  .app .photo-cell .photo-slot { flex: 1; }
  .app .gw-photo-remove {
    background: none; border: none; padding: 0;
    font: inherit; font-size: .72rem;
    color: #c0392b; text-decoration: underline; cursor: pointer;
  }
  .app .gw-photo-remove[hidden] { display: none; }

  /* ---------- Login banner ---------- */
  .app .login-banner {
    background: #e3f0fa;
    border-left: 4px solid #006298;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: .88rem;
    margin-bottom: 14px;
  }

  /* ---------- Sticky bottom action bar ---------- */
  .app .action-bar {
    position: sticky;
    bottom: 0;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e0e3e8;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
    z-index: 10;
    margin: 0 -16px;
  }
  .app .action-bar .btn { width: 100%; }
  .app .action-bar .meta {
    font-size: .75rem; color: var(--gw-text-soft);
    text-align: center; margin-top: 6px;
  }
  /* "What is missing" list shown in the submit bar when a tap on Submit finds
     empty required fields (2026-10-17). Each line is a link to the field. */
  .app .m-error-summary {
    background: var(--gw-danger-bg, #fde8e7);
    border: 1px solid var(--gw-danger, #b3261e);
    border-left-width: 4px;
    border-radius: 6px;
    color: #7a1a16;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: .85rem;
    max-height: 38vh;
    overflow-y: auto;
  }
  .app .m-error-summary strong { display: block; margin-bottom: 4px; }
  .app .m-error-summary ul { margin: 0; padding-left: 18px; }
  .app .m-error-summary li { margin: 2px 0; }
  .app .m-error-summary a {
    color: var(--gw-danger, #b3261e);
    font-weight: 600;
    text-decoration: underline;
  }

  /* ---------- Bottom tab nav (removed 2026-10-17: the county header already carries navigation; layout/mobile-bottom-nav.jsp is no longer included) ---------- */
  .app .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e0e3e8;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: 60px;
    z-index: 20;
  }
  .app .bottom-nav a {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-size: .68rem;
    color: var(--gw-text-soft);
    gap: 2px;
    text-decoration: none;
  }
  .app .bottom-nav a .ic { font-size: 1.25rem; }
  .app .bottom-nav a .nav-ic {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    color: inherit;
  }
  .app .bottom-nav a.active { color: #004e7a; font-weight: 700; }
  .app .bottom-nav a.active .nav-ic { color: #004e7a; }

  /* ---------- Status badges (mobile-styled) ---------- */
  .app .badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
  }
  .app .badge-submitted { background: #eef2f7; color: #3b4a5a; }
  .app .badge-ack       { background: #e3f0fa; color: #3a3838; }
  .app .badge-progress  { background: #fdf3e0; color: #6b3f00; }
  .app .badge-resolved  { background: #e6f4e6; color: #1f5921; }
  .app .badge-closed    { background: #ddd; color: #444; }

  /* ---------- Request list rows ---------- */
  .app .req-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e0e3e8;
    background: #fff;
    text-decoration: none;
    color: inherit;
  }
  .app .req-row:last-child { border-bottom: none; }
  .app .req-row:active { background: var(--gw-bg-soft); }
  .app .req-row .ic-wrap {
    width: 42px; height: 42px;
    background: #e3f0fa;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
  }
  .app .req-row .body { flex: 1; min-width: 0; }
  .app .req-row .body .t { font-weight: 600; font-size: .95rem; }
  .app .req-row .body .s { font-size: .8rem; color: var(--gw-text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app .req-row .body .m { font-size: .72rem; color: var(--gw-text-soft); margin-top: 2px; }

  /* ---------- Timeline ---------- */
  .app .timeline {
    list-style: none; padding: 0; margin: 0;
    border-left: 2px solid #e0e3e8;
    margin-left: 8px;
  }
  .app .timeline li { position: relative; padding: 4px 0 16px 18px; }
  .app .timeline li::before {
    content: ""; position: absolute;
    left: -7px; top: 8px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #006298;
    border: 2px solid #fff;
  }
  .app .timeline li.done::before { background: #2e7d32; }
  .app .timeline li.pending::before { background: #cfd6de; }
  .app .timeline .what { font-weight: 600; font-size: .92rem; }
  .app .timeline .when { font-size: .78rem; color: var(--gw-text-soft); }
  .app .timeline .note { font-size: .85rem; margin-top: 3px; white-space: pre-line; }

  /* ---------- Misc ---------- */
  .app .flex { display: flex; gap: 10px; align-items: center; }
  .app .flex-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
  /* gw- prefixed on purpose. Clay ships the same short names as spacing
     utilities and declares them !important, so a bare .mt-8 in this portlet was
     resolving to Clay's 7.5rem (120px) — a dead band under the map that only
     appeared once the park field was unhidden. A portlet cannot outrank an
     !important utility by specificity, so the names must not collide. */
  .app .gw-mt-8  { margin-top: 8px; }
  .app .gw-mt-12 { margin-top: 12px; }
  .app .gw-mt-16 { margin-top: 16px; }
  .app .gw-mb-0  { margin-bottom: 0; }
  .app .divider { height: 1px; background: #e0e3e8; margin: 12px 0; }

  /* ---------- Toast ---------- */
  .toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #0d2240;
    color: #fff;
    padding: 10px 16px;
    border-radius: 24px;
    font-size: .85rem;
    z-index: 90;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
}
