/*
 * Great Living Hua Hin — shared interaction states (hover, active, focus, disabled,
 * loading, external links). Loaded after site.css on every public page.
 *
 * Rules sit in their own cascade layer, declared after site.css's layers, so they
 * win over Tailwind utilities without !important. Only state styles live here.
 * Colours come from the design tokens defined in site.css (--color-*).
 */
@layer interactions {

:root {
    --ix-fast: 150ms;
    --ix: 180ms;
    --ix-ease: cubic-bezier(.4, 0, .2, 1);
    --ix-terracotta-press: #8a3d2b;
    --ix-shadow-lift: 0 10px 24px -14px rgb(24 44 61 / .35), 0 2px 6px -2px rgb(24 44 61 / .12);
    --ix-ring: 0 0 0 3px rgb(65 103 123 / .32);
    --ix-success-bg: #e8f3ec;
    --ix-success-border: #2e7d4f;
    --ix-success-text: #1d4d31;
    --ix-error-bg: #fbecea;
    --ix-error-border: #b42318;
    --ix-error-text: #7a1a12;
}

html { -webkit-tap-highlight-color: rgb(183 85 61 / .15); }

/* ---------- Pointer cursor on everything clickable ---------- */
a[href], button, [role="button"], summary, select, label:has(> input[type="checkbox"]),
input[type="checkbox"], input[type="radio"], input[type="submit"] { cursor: pointer; }

/* ---------- Focus (keyboard) ---------- */
:focus-visible { outline: 3px solid var(--color-coastal); outline-offset: 3px; }
/* On dark sections the coastal ring would vanish — switch to ivory */
.bg-coastal :focus-visible, .bg-navy :focus-visible { outline-color: var(--color-ivory); }

/* ---------- Buttons ---------- */
.btn {
    cursor: pointer;
    transition: background-color var(--ix) var(--ix-ease), color var(--ix) var(--ix-ease),
        border-color var(--ix) var(--ix-ease), box-shadow var(--ix) var(--ix-ease),
        translate var(--ix) var(--ix-ease), scale var(--ix-fast) var(--ix-ease), opacity var(--ix) var(--ix-ease);
}
@media (hover: hover) {
    .btn:hover:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) { translate: 0 -1px; box-shadow: var(--ix-shadow-lift); }
    .btn-primary:hover:not(:disabled, [aria-busy="true"]) { background-color: var(--color-terracotta-deep); }
    .btn-secondary:hover:not(:disabled, [aria-busy="true"]) { background-color: var(--color-navy); color: #fff; border-color: var(--color-navy); }
}
/* Pressed — also the tap state on touch screens */
.btn:active:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) { translate: 0 1px; scale: .98; box-shadow: none; }
.btn-primary:active:not(:disabled, [aria-busy="true"]) { background-color: var(--ix-terracotta-press); }
.btn-secondary:active:not(:disabled, [aria-busy="true"]) { background-color: var(--color-navy); color: #fff; }

/* ---------- Disabled ---------- */
.btn:disabled, .btn[aria-disabled="true"], button:disabled,
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Loading button (submit) ---------- */
.btn[aria-busy="true"] { opacity: .9; cursor: progress; }
.btn[aria-busy="true"]::before {
    content: ""; width: 1em; height: 1em; flex-shrink: 0;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: ix-spin .7s linear infinite;
}
@keyframes ix-spin { to { rotate: 360deg; } }

/* ---------- Links (menu, content, footer) ---------- */
a:not(.btn) {
    text-underline-offset: 4px;
    transition: color var(--ix) var(--ix-ease), text-decoration-color var(--ix) var(--ix-ease), opacity var(--ix) var(--ix-ease);
}
@media (hover: hover) {
    a:not(.btn):hover { text-decoration-line: underline; text-decoration-thickness: 2px; text-decoration-color: var(--color-terracotta); }
    a.text-coastal:hover, .rich a:hover { color: var(--color-navy); }
    .bg-coastal a:not(.btn):hover, .bg-navy a:not(.btn):hover { text-decoration-color: currentColor; }
}
a:not(.btn):active { text-decoration-line: underline; text-decoration-thickness: 2px; }

/* Main menu: hover underline; the current page keeps a terracotta underline */
#site-nav a:not(.btn) { text-underline-offset: 8px; text-decoration-thickness: 2px; }
@media (hover: hover) {
    #site-nav a:not(.btn):hover { color: var(--color-coastal); text-decoration-line: underline; text-decoration-color: currentColor; }
}
#site-nav a[aria-current="page"], #site-nav a[aria-current="page"]:hover {
    text-decoration-line: underline; text-decoration-color: var(--color-terracotta); text-decoration-thickness: 2px;
}

/* ---------- Cards (home, guide, neighbourhood) ---------- */
.card { transition: translate var(--ix) var(--ix-ease), box-shadow var(--ix) var(--ix-ease), scale var(--ix-fast) var(--ix-ease); }
.card img { transition: scale var(--ix) var(--ix-ease), opacity var(--ix) var(--ix-ease); }
@media (hover: hover) {
    .card:hover { translate: 0 -3px; box-shadow: var(--ix-shadow-lift); }
    .card:hover img { scale: 1.03; }
}
.card:active { translate: 0 0; scale: .99; box-shadow: 0 2px 8px -4px rgb(24 44 61 / .25); }

/* ---------- Form fields ---------- */
:is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"]), select, textarea) {
    transition: border-color var(--ix) var(--ix-ease), box-shadow var(--ix) var(--ix-ease);
}
@media (hover: hover) {
    :is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"]), select, textarea):hover:not(:disabled, :focus) {
        border-color: rgb(24 44 61 / .65);
    }
}
:is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"]), select, textarea):focus {
    border-color: var(--color-coastal); box-shadow: var(--ix-ring); outline: none;
}
:is(input, select, textarea)[aria-invalid="true"] { border-color: var(--ix-error-border); }
.bg-coastal :is(input:not([type="checkbox"], [type="radio"]), select, textarea):focus { box-shadow: 0 0 0 3px rgb(255 255 255 / .9); }

/* ---------- Form result messages ---------- */
.alert { display: flex; gap: .75rem; align-items: flex-start; border-left: 4px solid; border-radius: var(--radius-soft); padding: 1rem 1.25rem; }
.alert svg { flex-shrink: 0; width: 1.5rem; height: 1.5rem; margin-top: .15rem; }
.alert-success { background: var(--ix-success-bg); border-color: var(--ix-success-border); color: var(--ix-success-text); }
.alert-error { background: var(--ix-error-bg); border-color: var(--ix-error-border); color: var(--ix-error-text); }
.alert :is(h2, h3, p, a) { color: inherit; }

/* ---------- Home filters: results loading ---------- */
[data-results] { position: relative; }
[data-results] [data-results-body] { transition: opacity var(--ix) var(--ix-ease); }
[data-results][aria-busy="true"] [data-results-body] { opacity: .4; pointer-events: none; }
[data-results][aria-busy="true"] [data-results-body] img,
[data-results][aria-busy="true"] [data-results-body] [role="img"] {
    background: linear-gradient(100deg, var(--color-sand) 30%, var(--color-ivory) 50%, var(--color-sand) 70%) 0 0 / 200% 100%;
    animation: ix-shimmer 1.2s linear infinite;
}
@keyframes ix-shimmer { to { background-position: -200% 0; } }
[data-results][aria-busy="true"] [data-results-status]::before {
    content: ""; display: inline-block; width: .9em; height: .9em; margin-inline-end: .5em; vertical-align: -.1em;
    border: 2px solid var(--color-terracotta); border-right-color: transparent; border-radius: 50%;
    animation: ix-spin .7s linear infinite;
}

/* ---------- Page change progress bar ---------- */
.page-progress {
    position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; pointer-events: none;
    background: var(--color-terracotta); transform-origin: 0 50%; scale: 0 1; opacity: 0;
}
.page-progress.is-active { opacity: 1; scale: .8 1; transition: scale 8s cubic-bezier(.1, .7, .2, 1), opacity var(--ix-fast); }
.page-progress.is-active.is-start { scale: .15 1; transition: scale 200ms ease-out; }

/* ---------- Images: sand placeholder, fade in when loaded ---------- */
.js img.img-fade { opacity: 0; }
.js img.img-fade.is-loaded { opacity: 1; transition: opacity 200ms var(--ix-ease), scale var(--ix) var(--ix-ease); }

/* ---------- External links / app links (LINE, WhatsApp) ---------- */
a[target="_blank"]::after,
a[href^="https://wa.me/"]::after,
a[href^="https://line.me/"]::after {
    content: ""; display: inline-block; flex-shrink: 0; width: .85em; height: .85em;
    margin-inline-start: .4em; vertical-align: -.05em; background-color: currentColor;
    -webkit-mask: var(--ix-icon) center / contain no-repeat; mask: var(--ix-icon) center / contain no-repeat;
}
/* Arrow out of a box = opens in a new tab */
a[target="_blank"] {
    --ix-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6'/%3E%3Cpath d='M20 4l-9 9'/%3E%3Cpath d='M19 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E");
}
/* Chat bubble = opens the WhatsApp / LINE app */
a[href^="https://wa.me/"], a[href^="https://line.me/"] {
    --ix-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.6 7.1L4 20.5l1.4-5A8 8 0 1 1 21 12z'/%3E%3C/svg%3E");
}

/* ---------- Reduced motion: no movement, no animation ---------- */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after { transition-duration: 0s !important; animation: none !important; scroll-behavior: auto !important; }
    .btn:hover, .btn:active, .card:hover, .card:active { translate: none !important; scale: none !important; }
    .card:hover img { scale: none !important; }
    .page-progress.is-active { scale: 1 1; }
}

}

/* Laptop widths (1024-1279px): tighter main menu so seven items, the button and EN/TH fit on one line */
@media (min-width: 1024px) and (max-width: 1279px) {
    header.sticky > .container-site { column-gap: .75rem; }
    #site-nav ul { column-gap: .8rem; }
    #site-nav > div { column-gap: .8rem; }
    #site-nav ul a { font-size: .9rem; }
}
@media (min-width: 1024px) and (max-width: 1199px) {
    header.sticky > .container-site { column-gap: .5rem; }
    header .container-site > a:first-child { font-size: 1.125rem; }
    #site-nav ul, #site-nav > div { column-gap: .5rem; }
    #site-nav ul a { font-size: .875rem; }
    #site-nav .btn { padding-inline: .75rem; }
}
@media (min-width: 1024px) and (max-width: 1099px) {
    header.sticky > .container-site > a:first-child { white-space: normal; max-width: 8.5rem; }
}
