/* Use the same bundled Thai fonts as the staff application. */
@font-face {
  font-family: "Noto Sans Thai";
  src: url("/assets/assets/fonts/NotoSansThai-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Thai";
  src: url("/assets/assets/fonts/NotoSansThai-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Thai";
  src: url("/assets/assets/fonts/NotoSansThai-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Thai";
  src: url("/assets/assets/fonts/NotoSansThai-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Thai";
  src: url("/assets/assets/fonts/NotoSansThai-ExtraBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --navy: #0a2d5b;
  --ink: #102c4e;
  --muted: #48627b;
  --blue: #184b88;
  --sky: #eaf4fe;
  --line: #c7d8e8;
  --yellow: #ffcd36;
  --green: #087443;
  --gutter: clamp(14px, 4vw, 64px);
  font-family: "Noto Sans Thai", system-ui, Tahoma, sans-serif;
  color: var(--ink);
  background: #f5f9fd;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.52; }
h1, h2, h3, p, dl, dd, ul, figure { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, a, select, label:has(input[type="radio"]) { -webkit-tap-highlight-color: transparent; }
button, select, a[href] { cursor: pointer; }
:focus-visible { outline: 3px solid #1667ae; outline-offset: 3px; }
img { display: block; max-width: 100%; }
a { color: var(--blue); }
.shell { width: min(calc(100% - 2 * var(--gutter)), 1280px); margin-inline: auto; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10; padding: 10px 16px; transform: translateY(-160%); background: white; }
.skip-link:focus { transform: none; }
.store-header { background: white; border-bottom: 1px solid var(--line); }
.header-inner, .brand, .contact-actions, .detail-contact, .product-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.header-inner { justify-content: space-between; min-height: 58px; padding-block: 6px; }
.brand { flex-wrap: nowrap; gap: 10px; min-width: 0; }
.brand-name { color: var(--navy); font-size: clamp(1rem, 2.5vw, 1.28rem); font-weight: 780; overflow-wrap: anywhere; }
.brand-mark { width: 33px; height: 33px; border-radius: 10px; background: var(--navy); display: grid; position: relative; place-items: center; flex: none; }
.brand-mark:empty::before { content: ""; width: 13px; height: 22px; border: 2px solid #fff; border-radius: 4px; transform: rotate(12deg); }
.brand-mark:empty::after { content: ""; width: 5px; height: 2px; background: #fff; position: absolute; bottom: 9px; }
.brand-mark :is(img, svg) { width: 23px; height: 23px; object-fit: contain; }
.button, .hero-cta { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; font: inherit; font-weight: 700; font-size: .875rem; text-decoration: none; background: var(--navy); color: white; }
.button-secondary, .refresh-button, .detail-close { color: var(--navy); border-color: #a7bfd5; background: white; }
.contact-line { color: white; background: var(--green); border-color: var(--green); }
.button svg { width: 18px; height: 18px; }
button:disabled, input:disabled, select:disabled { opacity: .64; cursor: default; }
main.shell { width: 100%; }
main > .catalog { width: min(calc(100% - 2 * var(--gutter)), 1280px); margin-inline: auto; }
.hero {
  position: relative; isolation: isolate; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr);
  align-items: center; gap: 5%; min-height: clamp(250px, 26vw, 350px); margin: 0 0 28px;
  padding: clamp(24px, 3vw, 44px) max(var(--gutter), calc((100% - 1220px) / 2)); overflow: hidden;
  background: linear-gradient(105deg, #f4faff 2%, #e1f0ff 56%, #b8d9f5); border-bottom: 1px solid #c4d9ec;
}
.hero::before, .hero::after { content: ""; position: absolute; z-index: -1; pointer-events: none; }
.hero::before { width: 62%; aspect-ratio: 1; border-radius: 50%; right: -10%; top: 50%; transform: translateY(-50%); background: radial-gradient(circle at 44% 42%, #f7fbff 12%, #e1f1ff 60%, #c1def6 73%); box-shadow: 0 0 0 1px #ffffffa8, 0 0 0 24px #dfedfa65, 0 0 0 25px #ffffff70; }

.hero-copy { position: relative; z-index: 1; min-width: 0; display: grid; justify-items: start; align-content: center; gap: 7px; overflow-wrap: anywhere; }
.hero-copy > * { max-width: 100%; }
.hero-title { color: var(--navy); font-size: clamp(2.1rem, 5.2vw, 4.75rem); line-height: 1.1; letter-spacing: -.045em; }
.hero-description, .hero-eyebrow { color: var(--muted); font-weight: 600; font-size: clamp(.82rem, 1.3vw, 1rem); }
.hero-price { color: var(--navy); font-size: clamp(1.35rem, 2.6vw, 2.3rem); line-height: 1.22; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-cta { margin-top: 5px; background: var(--navy); color: white; }
.hero-visual { margin-block: -12px; align-self: stretch; min-width: 0; position: relative; }
.hero-image { transform: scale(1.10); position: absolute; inset: 0; margin: auto; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.hero:not(:has(.hero-image)) { min-height: 135px; grid-template-columns: 1fr; }
.image-caption { position: absolute; bottom: 9px; right: 10px; padding: 2px 7px; color: var(--muted); background: #fffffff0; border-radius: 5px; font-size: .7rem; }
.hero-visual .image-caption { bottom: 2px; right: 2px; }
.catalog { scroll-margin-top: 12px; padding-bottom: 34px; }
#catalog-title { position: static; color: var(--navy); font-size: clamp(1.35rem, 2.1vw, 1.95rem); letter-spacing: -.025em; line-height: 1.3; margin-bottom: 12px; }
.filters { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 26px; align-items: end; padding: 12px 0 15px; border-block: 1px solid var(--line); }
.condition-field { padding: 0; margin: 0; min-width: 0; border: 0; }
.field, .condition-field legend { font-size: .79rem; font-weight: 650; color: var(--muted); }
.condition-field legend { padding: 0; margin-bottom: 4px; }
.condition-options { display: inline-flex; gap: 2px; background: #deebf6; border-radius: 9px; padding: 2px; }
.condition-option { position: relative; display: grid; cursor: pointer; }
.condition-option input { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
.condition-option span { display: grid; place-items: center; min-height: 44px; padding: 4px 16px; border-radius: 7px; font-size: .865rem; font-weight: 650; }
.condition-option input:checked + span { background: var(--navy); color: white; }
.condition-option input:focus-visible + span { outline: 3px solid #1667ae; outline-offset: 2px; }
.filter-fields { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; min-height: 46px; padding: 8px 10px; background: white; color: var(--ink); border: 1px solid #aabfd3; border-radius: 8px; font-size: 1rem; font-weight: 400; }
.catalog-heading { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin: 8px 0; }
.stock-status { font-size: .9rem; color: var(--muted); font-weight: 650; }
.refresh-button { background: transparent; border-color: transparent; font-size: .8rem; }
.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(12px, 1.45vw, 22px); }
.product-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 4px 18px #0a2d5b08; }
.product-media, .detail-gallery { display: grid; place-items: center; position: relative; isolation: isolate; overflow: hidden; background: linear-gradient(145deg, #f8fbfe, #edf4fa); }
.product-media { aspect-ratio: 1.55; border-radius: 15px 15px 0 0; }
.product-image, .detail-image { position: absolute; inset: 0; width: 100%; height: 100%; padding: 12px; object-fit: contain; mix-blend-mode: multiply; }
.product-media:has(.image-caption) .product-image { padding-bottom: 19px; }
.image-placeholder { display: grid; place-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.image-placeholder-icon { width: 24px; height: 39px; border: 2px solid #8ba5bc; border-radius: 6px; }
.product-body { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: clamp(12px, 1.4vw, 19px); gap: 5px; }
.product-meta, .detail-specs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.product-meta, .product-spec, .detail-specs dt { color: var(--muted); font-size: .8rem; }
.condition-tag { display: inline-flex; align-self: start; width: fit-content; padding: 2px 7px; border-radius: 5px; background: #e8f0f8; color: var(--navy); font-size: .75rem; font-weight: 700; }
.product-title { font-size: clamp(1.1rem, 1.6vw, 1.5rem); line-height: 1.25; color: var(--navy); }
.product-body, .detail-info { overflow-wrap: anywhere; }
.price-block { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 10px; margin-top: 2px; padding-top: 7px; }
.price-label { font-size: .8rem; color: var(--muted); }
.cash-price { font-size: clamp(1.5rem, 2.5vw, 2rem); font-weight: 800; line-height: 1.3; letter-spacing: -.035em; }
.installment-summary { width: 100%; margin: 4px 0; color: var(--muted); font-size: .83rem; }
.down-payment { display: inline-flex; align-items: stretch; border-radius: 6px; overflow: hidden; }
.down-payment-label, .down-payment-value { display: inline-flex; align-items: center; padding: 3px 9px; font-weight: 750; }
.down-payment-label { background: var(--navy); color: white; }
.down-payment-value { background: var(--yellow); color: var(--navy); font-variant-numeric: tabular-nums; }
.installment-options { display: flex; flex-wrap: wrap; gap: 5px; padding: 0; margin: 6px 0 0; list-style: none; }
.installment-option { display: grid; padding: 4px 8px; border: 1px solid var(--line); background: #f6faff; border-radius: 6px; }
.installment-amount { font-size: .99rem; font-weight: 750; color: var(--ink); }
.installment-term { font-size: .75rem; }
.product-actions { margin-top: auto; padding-top: 8px; border-top: 1px solid #e0e9f2; gap: 5px; }
.product-actions .button { min-height: 44px; padding: 6px 10px; font-size: .81rem; }
.product-button { margin-right: auto; }
.status-card, .plan-section { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.status-copy, .plan-section p { color: var(--muted); }
.status-card .button { margin-top: 10px; }
.store-footer { padding-block: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.detail-dialog { width: min(calc(100% - 28px), 850px); max-height: 90dvh; overflow: auto; overscroll-behavior: contain; padding: 16px; border: 1px solid var(--line); border-radius: 19px; color: var(--ink); }
.detail-dialog::backdrop { background: #0a2447aa; }
.detail-dialog form { text-align: right; }
.detail-content { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 20px; margin-top: 6px; }
.detail-gallery { aspect-ratio: 1; border-radius: 12px; }
.detail-info { display: grid; justify-items: start; gap: 10px; min-width: 0; }
.detail-info h2 { line-height: 1.25; }
.detail-specs { align-items: start; }
.detail-specs dd { font-weight: 650; }
.plan-section { width: 100%; padding: 12px; }
.plan-list { padding: 0; list-style: none; }
@media (hover: hover) { .button:not(:disabled):hover, .hero-cta:hover { filter: brightness(.92); } }
@media (max-width: 980px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 720px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { min-height: 220px; padding: 22px; gap: 4%; }
  .hero-visual .image-caption { bottom: -9px; }
}
@media (max-width: 540px) {
  /* Phones: the shop name and its LINE/call buttons share one row. */
  .header-inner { min-height: 52px; flex-wrap: nowrap; gap: 8px; }
  .brand { flex: 1 1 auto; }
  .brand-name {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    font-size: .98rem; line-height: 1.25;
  }
  .contact-actions { flex: none; flex-wrap: nowrap; gap: 6px; }
  .contact-actions .button { min-height: 38px; padding: 4px 10px; font-size: .78rem; }
  /* Phones: the featured phone stays, but short, so the list starts on the
     first screen. */
  .hero {
    min-height: 0; margin: 0 0 10px; padding: 12px var(--gutter);
    grid-template-columns: minmax(0, 1.4fr) minmax(0, .6fr); gap: 6px;
  }
  .hero-visual { margin-block: 0; }
  .hero-visual .image-caption { bottom: 0; right: 0; }
  .hero-copy { gap: 3px; }
  .hero-title { font-size: clamp(1.45rem, 6.6vw, 2.1rem); }
  .hero-description, .hero-eyebrow { font-size: .74rem; }
  .hero-price { font-size: 1.25rem; }
  .hero-installment { font-size: .8rem; }
  .hero-installment .down-payment { font-size: .9rem; }
  .hero-cta { margin-top: 3px; padding-inline: 10px; font-size: .8rem; }
  .hero-image { height: 96%; transform: none; }
  #catalog-title { font-size: 1.15rem; margin-bottom: 4px; }
  .filters { gap: 6px; padding-block: 6px; }
  /* The three choices name themselves; the label stays for screen readers. */
  .condition-field legend {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .condition-options { display: flex; }
  .condition-option { flex: 1; }
  .condition-option span { padding-inline: 6px; }
  .filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
  .search-field { grid-column: 1 / -1; }
  .field input, .field select { min-height: 44px; padding-block: 5px; }
  .catalog-heading { margin: 4px 0; }
  .detail-dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .detail-content { grid-template-columns: 1fr; }
  .detail-gallery { aspect-ratio: 1.8; }

  /* Phones: two compact cards per row. */
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .product-card { border-radius: 12px; box-shadow: 0 2px 10px #0a2d5b0a; }
  .product-media { aspect-ratio: 1.35; border-radius: 11px 11px 0 0; }
  .product-image { padding: 8px; }
  .product-media:has(.image-caption) .product-image { padding-bottom: 17px; }
  .product-media .image-caption { bottom: 4px; right: 4px; padding: 1px 5px; font-size: .62rem; }
  .image-placeholder { gap: 5px; padding-inline: 6px; text-align: center; font-size: .7rem; }
  .image-placeholder-icon { width: 19px; height: 31px; }
  .product-body { padding: 8px 9px 9px; gap: 2px; }
  /* One line of type and branch (the full branch is in the details), and at
     most two lines of storage, colour and condition. */
  .product-meta { flex-wrap: nowrap; gap: 2px 6px; }
  .product-meta > * { flex: none; }
  .product-meta .product-branch { flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .product-meta, .product-spec { font-size: .7rem; line-height: 1.35; }
  .product-spec { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .condition-tag { padding: 1px 6px; font-size: .68rem; }
  .product-title { font-size: 1rem; line-height: 1.25; }
  .price-block { gap: 0 6px; margin-top: 1px; padding-top: 3px; }
  .price-label { font-size: .7rem; }
  .cash-price { font-size: 1.2rem; }
  .installment-summary { margin: 2px 0; font-size: .72rem; }
  .down-payment-label, .down-payment-value { padding: 2px 6px; font-size: .74rem; }
  .installment-options { gap: 4px; margin-top: 4px; }
  .installment-option { padding: 2px 6px; }
  .installment-amount { font-size: .84rem; }
  .installment-term { font-size: .66rem; }
  .product-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; padding-top: 6px; }
  .product-actions .button { min-width: 0; min-height: 40px; padding: 4px 6px; font-size: .76rem; }
  /* Details across the card; LINE and call share the row below, or one of
     them takes it whole. */
  .product-actions .product-button,
  .product-actions .button:nth-child(2):last-child { grid-column: 1 / -1; }
  .product-button { margin-right: 0; }
}

.hero-installment { color: var(--ink); font-size: .88rem; }
.hero-installment .installment-options { margin-top: 2px; }
.hero-installment .installment-option { display: flex; gap: 5px; align-items: baseline; padding: 0; border: 0; background: none; }
.hero-installment .down-payment { font-size: 1.03rem; }
.hero-installment .installment-term { color: var(--muted); }
.filter-details { min-width: 0; }
.filter-summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 2px; cursor: pointer;
  color: var(--navy); font-size: .88rem; font-weight: 700; list-style: none;
}
.filter-summary::-webkit-details-marker { display: none; }
.filter-summary::after {
  content: ""; margin-left: auto; margin-right: 6px; width: 9px; height: 9px;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.filter-details[open] .filter-summary::after { transform: rotate(225deg); }
.filter-count { font-size: .78rem; padding: 1px 8px; color: white; background: var(--navy); border-radius: 12px; }
@media (min-width: 651px) {
  .filter-details[open] .filter-summary { display: none; }
}
@media (max-width: 650px) {
  .filters { gap: 4px; }
  .filter-details[open] .filter-fields { margin-bottom: 8px; }
}

/* Detail gallery: one large photo, its place among the others, previous and
   next, and a strip of small photos. */
.detail-media { display: grid; gap: 10px; min-width: 0; }
.detail-gallery { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.detail-gallery:focus-visible { outline-offset: -3px; }
.gallery-view { position: absolute; inset: 0; display: grid; place-items: center; }
.gallery-view img { -webkit-user-drag: none; }
.gallery-nav {
  position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; transform: translateY(-50%);
  color: var(--navy); background: #fffffff2; border: 1px solid #a7bfd5; border-radius: 50%;
  box-shadow: 0 2px 8px #0a2d5b26;
}
.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }
.gallery-nav::before {
  content: ""; width: 11px; height: 11px; margin-left: 4px;
  border: solid currentColor; border-width: 0 0 3px 3px; transform: rotate(45deg);
}
.gallery-next::before { margin-left: 0; margin-right: 4px; transform: rotate(225deg); }
.gallery-position {
  position: absolute; z-index: 2; top: 10px; right: 10px; padding: 2px 10px;
  color: white; background: var(--navy); border-radius: 999px;
  font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.gallery-thumbs {
  display: flex; gap: 8px; margin: 0; padding: 3px 3px 6px; list-style: none;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
}
.gallery-thumb-item { flex: none; scroll-snap-align: center; }
.gallery-thumb {
  display: block; width: 56px; height: 56px; padding: 3px; overflow: hidden;
  background: white; border: 2px solid var(--line); border-radius: 9px;
}
.gallery-thumb[aria-current="true"] { border-color: var(--navy); box-shadow: 0 0 0 2px var(--yellow); }
.gallery-thumb-image { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.product-photos { color: var(--muted); font-size: .8rem; }

/* Condition and battery, set apart in the details. */
.detail-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; width: 100%; }
.detail-fact {
  min-width: 0; padding: 8px 12px; background: #f6faff;
  border: 1px solid var(--line); border-left: 5px solid var(--yellow); border-radius: 9px;
}
.detail-fact dt { color: var(--muted); font-size: .78rem; }
.detail-fact dd { color: var(--navy); font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 540px) {
  .gallery-thumb { width: 52px; height: 52px; }
}
