/* Heritage Fiji V3.18 — final frontend QA, dark-mode and accessibility polish
   Deliberately appended after V3.17 so the approved visual design and layout remain intact. */
:root{--v318-focus:#e0bd4f;--v318-dark-surface:#17241b;--v318-dark-raised:#1d2d22;--v318-dark-line:rgba(238,244,239,.16)}
html{color-scheme:light}
html[data-theme="dark"]{color-scheme:dark}

/* Reliable focus and keyboard visibility */
.skip-link{position:fixed!important;left:16px!important;top:12px!important;z-index:9999!important;transform:translateY(-160%);opacity:0;pointer-events:none}
.skip-link:focus-visible{transform:none;opacity:1;pointer-events:auto;background:var(--paper);color:var(--ink);border:2px solid var(--v318-focus);border-radius:8px;padding:10px 14px;box-shadow:var(--shadow)}
:is(a,button,input,select,textarea,[tabindex]):focus-visible{outline:3px solid color-mix(in srgb,var(--v318-focus) 88%,white)!important;outline-offset:3px!important}
input::placeholder,textarea::placeholder{color:color-mix(in srgb,var(--muted) 82%,transparent);opacity:1}

/* Dark theme: resolve legacy hard-coded light-theme colours. */
[data-theme="dark"] body{background:var(--cream);color:var(--ink)}
[data-theme="dark"] .site-header{background:rgba(19,32,23,.94)!important;border-bottom-color:var(--v318-dark-line)!important;box-shadow:0 8px 28px rgba(0,0,0,.18)}
[data-theme="dark"] .desktop-nav a{color:#eaf1eb!important}
[data-theme="dark"] .desktop-nav a:hover,[data-theme="dark"] .desktop-nav a.active,[data-theme="dark"] .desktop-nav a[aria-current="page"]{color:#f0d36a!important}
[data-theme="dark"] :is(.theme-button,.mobile-menu-button){background:#1c2d21!important;color:#eef4ef!important;border-color:rgba(238,244,239,.20)!important}
[data-theme="dark"] .account-button{background:#2b7d46!important;border-color:#2b7d46!important;color:#fff!important}
[data-theme="dark"] .mobile-menu{background:#17241b!important;border-color:var(--v318-dark-line)!important;box-shadow:0 26px 70px rgba(0,0,0,.42)!important}
[data-theme="dark"] .mobile-menu a,[data-theme="dark"] .mobile-account-link{color:#edf4ef!important}
[data-theme="dark"] .mobile-menu a:hover,[data-theme="dark"] .mobile-menu a[aria-current="page"]{background:#213226!important;color:#f0d36a!important}
[data-theme="dark"] .section-tint{background:color-mix(in srgb,var(--paper) 72%,#0a130d)!important}
[data-theme="dark"] :is(.card,.resource-card,.programme-card,.brand-shortcut,.directory-site-card,.directory-empty,.responsible-access-panel,.site-quick-strip,.home-status-strip,.account-card,.request-card,.form-card,.content-card,.editorial-quick,.visit-card,.contact-card){background:var(--paper)!important;border-color:var(--v318-dark-line)!important;color:var(--ink)!important}
[data-theme="dark"] :is(.brand-welcome h2,.brand-protect h2,.brand-stories h2,.brand-shortcut h3,.brand-shortcut b,.home-status-title strong,.responsible-access-panel h2,.directory-empty h3,.directory-site-card h3,.site-quick-grid strong,.section-heading h2,.content-card h2,.form-card h2,.card h2,.card h3,.resource-card h3,.programme-card h3,.account-card h2,.request-card h3){color:#eef4ef!important}
[data-theme="dark"] :is(.brand-welcome p,.brand-shortcut p,.responsible-access-panel p,.directory-empty p,.directory-site-card p,.section-heading .lead,.content-card p,.form-card p,.card p,.resource-card p,.programme-card p,.site-quick-grid span){color:#b7c5ba!important}
[data-theme="dark"] .btn-secondary{color:#eef4ef!important;border-color:rgba(238,244,239,.38)!important;background:rgba(255,255,255,.035)!important}
[data-theme="dark"] .btn-secondary:hover{background:rgba(255,255,255,.09)!important;border-color:rgba(238,244,239,.58)!important}
[data-theme="dark"] :is(.input,.select,.textarea,input:not([type="checkbox"]):not([type="radio"]),select,textarea){background:#122019!important;color:#eef4ef!important;border-color:rgba(238,244,239,.18)!important}
[data-theme="dark"] :is(.input,.select,.textarea,input,select,textarea):focus{border-color:#d6b84c!important;box-shadow:0 0 0 3px rgba(214,184,76,.16)!important}
[data-theme="dark"] option{background:#17241b;color:#eef4ef}
[data-theme="dark"] .modal{background:rgba(2,10,5,.72)!important}
[data-theme="dark"] .modal-card{background:#18271d!important;color:#eef4ef!important;border:1px solid rgba(238,244,239,.16)!important;box-shadow:0 34px 100px rgba(0,0,0,.48)!important}
[data-theme="dark"] .chat-panel{background:#17241b!important;color:#eef4ef!important;border-color:rgba(238,244,239,.16)!important;box-shadow:0 28px 80px rgba(0,0,0,.46)!important}
[data-theme="dark"] .chat-messages,[data-theme="dark"] .chat-suggestions{color:#dfe9e1}
[data-theme="dark"] .chat-input-row{border-top-color:rgba(238,244,239,.14)!important}
[data-theme="dark"] .page-breadcrumb:not(.light){color:#b3c2b6!important}
[data-theme="dark"] .home-status-item{color:#eef4ef!important}
[data-theme="dark"] .home-status-item:hover,[data-theme="dark"] .home-status-item:focus-visible{background:rgba(224,185,73,.08)!important}
[data-theme="dark"] .shortcut-icon{box-shadow:inset 0 0 0 1px rgba(255,255,255,.06)}
[data-theme="dark"] .featured-access,[data-theme="dark"] .access-pill,[data-theme="dark"] .map-preview-label{background:#f7f3e8!important;color:#173f2b!important}
[data-theme="dark"] .site-footer{box-shadow:0 -1px 0 rgba(255,255,255,.05)}

/* Form, modal and toast hardening */
:is(input,select,textarea,button){max-width:100%}
.modal-card{max-height:min(88dvh,900px);overflow:auto;overscroll-behavior:contain}
.toast{max-width:min(92vw,520px)}
.chat-panel{max-height:min(78dvh,680px)}
img{height:auto}

/* Mobile/iPhone reliability without redesigning layouts. */
@media(max-width:760px){
  .site-header{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right));gap:8px}
  .public-service-bar{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
  .mobile-menu{left:max(10px,env(safe-area-inset-left));right:max(10px,env(safe-area-inset-right));max-height:calc(100dvh - 110px);overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
  .mobile-menu a,.mobile-account-link{min-height:44px;display:flex;align-items:center}
  :is(.theme-button,.account-button,.mobile-menu-button){min-width:44px;min-height:44px}
  .btn{min-height:44px}
  .filter{min-height:40px}
  .modal{padding:max(10px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left))!important}
  .modal-card{width:min(100%,680px)!important;max-height:calc(100dvh - 24px)!important}
  .chat-launcher{bottom:max(16px,calc(env(safe-area-inset-bottom) + 8px))!important;right:max(14px,env(safe-area-inset-right))!important}
  .chat-panel{left:max(10px,env(safe-area-inset-left))!important;right:max(10px,env(safe-area-inset-right))!important;bottom:max(10px,env(safe-area-inset-bottom))!important;width:auto!important;max-height:calc(100dvh - 84px)!important}
  .site-footer{padding-bottom:max(32px,calc(env(safe-area-inset-bottom) + 22px))}
  .container{width:min(100% - 28px,1220px)}
  .directory-site-card,.home-action-feature,.home-story-lead,.explore-featured{contain:paint}
}
@media(max-width:430px){
  .ntf-brand{min-width:0!important;flex:1 1 auto}.ntf-logo{width:min(164px,42vw)!important}
  .account-button #accountLabel{display:none}.account-button{width:44px!important;padding:0!important;justify-content:center!important}
  .service-bar-contact{display:none!important}
  .service-bar-inner{justify-content:center;text-align:center}
  .section{padding-top:58px;padding-bottom:58px}
  .section-compact{padding-top:42px;padding-bottom:42px}
}

@media(prefers-reduced-motion:reduce){
  html{scroll-behavior:auto!important}
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
