/*
  Authoritative compact-density layer.
  Loaded after the shared and page-specific styles so phone proportions are
  controlled in one place. Wide-screen compositions remain untouched.
*/

@media (max-width: 767px) {
  :root {
    --header-height: 68px;
    --compact-gutter: 16px;
    --compact-section-block: 36px;
    --compact-card-radius: 14px;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .header-inner {
    width: calc(100% - 24px);
    height: var(--header-height);
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-title {
    font-size: 12.5px;
  }

  .brand-mobile-role {
    font-size: 8.5px;
  }

  .language-selector {
    width: 64px;
    height: 36px;
  }

  .language-option {
    width: 29px;
    height: 30px;
    font-size: 10px;
  }

  .menu-toggle {
    width: 34px;
    min-height: 44px;
  }

  .mobile-navigation {
    top: var(--header-height);
    height: calc(100dvh - var(--header-height));
    max-height: calc(100dvh - var(--header-height));
  }

  /* Homepage hero: one compact scene with the portrait still tied to copy. */
  .hero-inner {
    min-height: 570px;
    padding-top: max(20px, env(safe-area-inset-top));
  }

  .hero-eyebrow {
    margin-bottom: 11px;
    font-size: 8.5px;
  }

  .hero-title {
    font-size: clamp(33px, 9.8vw, 43px);
  }

  .hero-description {
    margin-top: 14px;
    font-size: clamp(12px, 3.3vw, 13.5px);
    line-height: 1.42;
  }

  .hero-name {
    margin-top: 9px;
    font-size: clamp(17px, 4.7vw, 20px);
  }

  .hero-actions {
    gap: 7px;
    margin-top: 10px;
  }

  .hero-button {
    min-height: 44px;
    font-size: 9.5px;
  }

  .hero-portrait {
    right: max(-42px, calc(env(safe-area-inset-right) - 42px));
    width: min(78vw, 310px);
  }

  .hero-tools {
    margin: 6px 10px 10px;
  }

  .hero-tools .home-tool,
  .hero-tools .home-tool:nth-child(2n),
  .hero-tools .home-tool:last-child {
    flex-basis: 70%;
    min-height: 58px;
    padding: 7px 10px;
  }

  /* Secretariat: preview breadth through swiping, not stacked height. */
  .secretariat-section {
    padding: 36px var(--compact-gutter) 40px;
  }

  .secretariat-heading {
    margin-bottom: 14px;
  }

  .secretariat-heading .section-eyebrow {
    margin-bottom: 10px;
  }

  .secretariat-heading h2 {
    font-size: clamp(32px, 9.2vw, 38px);
  }

  .secretariat-heading > p:last-child {
    margin-top: 7px;
    font-size: 11.5px;
  }

  .secretariat-card {
    flex-basis: min(82vw, 306px);
    min-height: 145px;
  }

  .secretariat-card-media {
    min-height: 145px;
  }

  .secretariat-card-body {
    padding: 12px;
  }

  .secretariat-card-body h3 {
    margin: 6px 0;
    font-size: clamp(18px, 5.4vw, 21px);
  }

  .secretariat-card-body > p:last-child {
    font-size: 10px;
    line-height: 1.36;
  }

  /* Homepage budget: three selectors in view and a denser evidence card. */
  .home-budget-section {
    padding: 38px 0 42px;
  }

  .home-budget-copy .section-eyebrow {
    margin-bottom: 10px;
    font-size: 9px;
  }

  .home-budget-copy h2 {
    font-size: clamp(33px, 9.6vw, 40px);
  }

  .home-budget-intro {
    margin-top: 13px;
    font-size: 13px;
    line-height: 1.44;
  }

  .home-budget-primary-link {
    min-height: 46px;
    margin-top: 15px;
    padding-inline: 15px;
    font-size: 12px;
  }

  .home-budget-panel {
    margin-top: 18px;
  }

  .home-budget-selectors {
    gap: 7px;
    padding-bottom: 5px;
  }

  .home-budget-selector {
    flex-basis: 96px;
    min-height: 100px;
    gap: 6px;
    padding: 9px 6px 7px;
    border-radius: 12px;
  }

  .home-budget-selector img {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .home-budget-selector-name {
    min-height: 34px;
    font-size: 10.5px;
    line-height: 1.12;
  }

  .home-budget-selector-check {
    top: 5px;
    right: 5px;
    width: 17px;
    height: 17px;
    font-size: 10px;
  }

  .home-budget-overview {
    margin-top: 13px;
    border-radius: 16px;
  }

  .home-budget-overview-heading {
    padding: 11px 12px 9px;
    font-size: 8.5px;
  }

  .home-budget-overview-heading strong {
    font-size: 8.5px;
  }

  .home-budget-government-row {
    padding: 10px 12px 11px;
  }

  .home-budget-government-heading {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 7px;
    margin-bottom: 4px;
  }

  .home-budget-government-icon {
    width: 28px;
    height: 28px;
    font-size: 15px;
  }

  .home-budget-government-heading strong {
    font-size: clamp(15px, 4.3vw, 17px);
  }

  .home-budget-stat,
  .home-budget-stat + .home-budget-stat {
    padding-block: 8px 9px;
  }

  .home-budget-stat span {
    font-size: 9px;
  }

  .home-budget-stat strong {
    margin-top: 3px;
    font-size: clamp(17px, 5.3vw, 20px);
  }

  .home-budget-evidence {
    padding: 9px 12px 11px;
    font-size: 9px;
  }

  .home-budget-evidence a {
    min-height: 32px;
    font-size: 11px;
  }

  /* People and Offices reference calibration. */
  .home-directory-section {
    padding: 32px var(--compact-gutter) 36px;
  }

  .home-directory-heading .section-eyebrow {
    margin-bottom: 10px;
    font-size: 9px;
  }

  .home-directory-heading h2 {
    font-size: clamp(34px, 9.9vw, 40px);
  }

  .home-directory-heading-copy > p {
    margin-top: 13px;
    font-size: 13px;
    line-height: 1.44;
  }

  .home-directory-link {
    min-height: 34px;
    margin-top: 7px;
    font-size: 12px;
  }

  .home-directory-toggle {
    min-height: 48px;
    margin-top: 12px;
    padding: 2px;
  }

  .home-directory-toggle-button {
    min-height: 44px;
    gap: 6px;
    padding-inline: 5px;
    font-size: clamp(9.5px, 2.75vw, 11.5px);
  }

  .home-directory-toggle-button i {
    font-size: 15px;
  }

  .home-directory-levels {
    gap: 7px;
    margin-top: 12px;
    padding-bottom: 5px;
  }

  .home-directory-level {
    flex-basis: 94px;
    min-height: 96px;
    gap: 5px;
    padding: 8px 6px 7px;
    border-radius: 12px;
  }

  .home-directory-level img {
    width: 36px;
    height: 36px;
  }

  .home-directory-level > span {
    min-height: 34px;
    font-size: 10.5px;
    line-height: 1.1;
  }

  .home-directory-level-check {
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    font-size: 9px;
  }

  .home-directory-panel {
    margin-top: 7px;
  }

  .home-directory-panel-card {
    border-radius: 15px;
  }

  .home-directory-panel-heading {
    gap: 7px;
    padding: 9px 10px 8px;
  }

  .home-directory-panel-identity {
    gap: 7px;
  }

  .home-directory-panel-identity > img {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .home-directory-panel-heading strong {
    font-size: clamp(15.5px, 4.5vw, 18px);
  }

  .home-directory-panel-identity span {
    font-size: 9px;
  }

  .home-directory-verified {
    min-height: 32px;
    max-width: 88px;
    gap: 4px;
    padding: 4px 6px;
    font-size: 8px;
    line-height: 1.15;
  }

  .home-directory-verified i {
    font-size: 13px;
  }

  .home-directory-people {
    display: block;
    padding: 0 10px;
  }

  .home-directory-person,
  .home-directory-person:first-child,
  .home-directory-person:nth-child(2),
  .home-directory-person:nth-child(n + 3) {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 9px;
    min-height: 84px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(7, 50, 74, .1);
  }

  .home-directory-person:last-child {
    border-bottom: 0;
  }

  .home-directory-person-photo {
    width: 54px;
    min-height: 68px;
    border-radius: 8px;
  }

  .home-directory-person-copy > p {
    font-size: 7.5px;
  }

  .home-directory-person-copy h3 {
    margin: 3px 0 5px;
    font-size: clamp(14px, 4vw, 16px);
    line-height: 1.05;
  }

  .home-directory-person-links {
    gap: 3px;
  }

  .home-directory-person-links a {
    gap: 5px;
    font-size: 9.5px;
    line-height: 1.25;
  }

  .home-directory-person-links a i {
    font-size: 12px;
  }

  .home-directory-mobile-cta {
    min-height: 44px;
    margin: 2px 10px 10px;
    font-size: 12px;
  }

  .home-directory-panel-footer {
    padding-top: 10px;
    font-size: 9.5px;
  }

  .home-directory-trust {
    gap: 7px;
  }

  .home-directory-trust > i {
    font-size: 17px;
  }

  /* Shared detail-page density. */
  .page-hero {
    padding: 36px var(--compact-gutter) 32px;
  }

  .page-hero h1 {
    font-size: clamp(34px, 9.8vw, 40px);
  }

  .page-hero-copy > p:last-child {
    margin-top: 13px;
    font-size: 13px;
    line-height: 1.44;
  }

  .page-hero-note {
    margin-top: 18px;
  }

  .page-section {
    padding: 36px var(--compact-gutter) 42px;
  }

  .section-head {
    margin-bottom: 16px;
  }

  .section-head h2,
  .contact-copy h2 {
    font-size: clamp(32px, 9.2vw, 37px);
  }

  .map-panel {
    min-height: 210px;
    padding: 16px;
  }

  .info-panel,
  .info-panel[style] {
    min-height: 170px !important;
    padding: 17px;
  }

  .contact-form {
    padding: 14px;
  }

  .contact-form textarea {
    min-height: 98px;
  }

  .budget-hero {
    padding: 36px var(--compact-gutter) 20px;
  }

  .page-hero.budget-hero h1 {
    font-size: clamp(36px, 10.5vw, 43px);
  }

  .budget-hero-summary-grid {
    margin-top: 16px;
  }

  .budget-hero-card:not(.budget-hero-card-central) {
    padding: 10px;
    border-radius: 14px;
  }

  .budget-hero-card:not(.budget-hero-card-central) > .budget-hero-card-row {
    min-height: 62px;
  }

  .budget-section {
    padding-top: 34px;
  }

  .budget-metric {
    flex-basis: min(62vw, 202px);
    min-height: 84px;
    padding: 10px;
  }

  .budget-chart-panel,
  .budget-records-panel,
  .budget-source-notes {
    padding-right: 10px;
    padding-left: 10px;
  }
}

/* The full directory uses the same municipality and portrait scale as the
   homepage preview, while keeping 44px ward and sector controls. */
@media (max-width: 620px) {
  .directory-hero {
    padding: 34px var(--compact-gutter) 32px;
  }

  .directory-hero-copy > p:last-child {
    margin-top: 12px;
    font-size: 12.5px;
  }

  .district-strip-heading {
    margin-top: 20px;
    margin-bottom: 8px;
  }

  .district-contact-card,
  .district-contact-card:nth-child(-n + 3) {
    flex-basis: min(66vw, 216px);
    min-height: 78px;
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 9px;
  }

  .district-contact-emblem {
    width: 42px;
    height: 42px;
  }

  .directory-browser {
    padding: 34px var(--compact-gutter) 40px;
  }

  .directory-heading-row {
    gap: 13px;
    margin-bottom: 12px;
  }

  .directory-heading-row h2 {
    font-size: clamp(32px, 9.2vw, 37px);
  }

  .sector-switch {
    min-height: 48px;
  }

  .local-level-rail {
    gap: 7px;
    margin-bottom: 9px;
  }

  .local-level-button {
    flex-basis: 94px;
    min-height: 94px;
    gap: 5px;
    padding: 7px 5px;
  }

  .local-level-logo {
    width: 36px;
    height: 36px;
  }

  .local-level-label strong {
    font-size: 9.5px;
    line-height: 1.08;
  }

  .directory-summary {
    padding: 10px;
  }

  .summary-heading {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 7px;
  }

  .summary-heading img {
    width: 38px;
    height: 38px;
  }

  .summary-heading h3 {
    font-size: 15.5px;
  }

  .directory-detail {
    padding: 12px 10px;
  }

  .detail-heading h3 {
    font-size: 17px;
  }

  .ward-rail {
    margin: 11px 0;
  }

  .member-table tr {
    padding: 8px 0;
  }

  .member-table-person {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
  }

  .member-table-person .person-avatar {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 359px) {
  :root {
    --compact-gutter: 14px;
  }

  .hero-inner {
    min-height: 552px;
  }

  .home-budget-selector,
  .home-directory-level,
  .local-level-button {
    flex-basis: 90px;
  }

  .home-directory-panel-heading {
    gap: 5px;
  }

  .home-directory-verified {
    max-width: 78px;
    padding-inline: 4px;
    font-size: 7.5px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .home-directory-section {
    padding-top: 58px;
    padding-bottom: 64px;
  }

  .home-directory-level {
    flex-basis: 170px;
    min-height: 84px;
    grid-template-columns: 48px minmax(0, 1fr);
    padding: 11px 12px;
  }

  .home-directory-level img {
    width: 48px;
    height: 48px;
  }

  .home-directory-person {
    min-height: 138px;
  }

  .home-directory-person-photo {
    width: 72px;
    min-height: 98px;
  }
}

@media (max-width: 767px) and (max-height: 500px) and (orientation: landscape) {
  :root {
    --header-height: 62px;
  }

  .header-inner {
    min-height: 62px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

  .brand-mobile-role {
    display: none;
  }

  .hero-inner {
    min-height: 310px;
    padding: 16px 20px 0;
  }

  .hero-content {
    max-width: 61%;
  }

  .hero-eyebrow {
    margin-bottom: 8px;
    font-size: 8px;
  }

  .hero-title {
    font-size: clamp(29px, 5.1vw, 34px);
    line-height: .94;
  }

  .hero-description {
    max-width: 100%;
    margin-top: 9px;
    font-size: 10.5px;
    line-height: 1.35;
  }

  .hero-name {
    max-width: 100%;
    margin-top: 5px;
    font-size: 15px;
  }

  .hero-actions {
    flex-direction: row;
    gap: 7px;
    width: min(62vw, 370px);
    margin-top: 8px;
  }

  .hero-button {
    min-height: 40px;
    font-size: 9px;
  }

  .hero-portrait {
    right: -8px;
    width: min(38vw, 250px);
  }

  .hero-tools {
    margin: 6px 16px 10px;
  }

  .hero-tools .home-tool,
  .hero-tools .home-tool:nth-child(2n),
  .hero-tools .home-tool:last-child {
    flex-basis: 46%;
    min-height: 54px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) and (max-height: 500px) and (orientation: landscape) {
  .hero-inner {
    min-height: 330px;
  }

  .hero-content {
    max-width: 57%;
    padding-top: 20px;
  }

  .hero-title {
    font-size: clamp(36px, 4.8vw, 42px);
  }

  .hero-description {
    margin-top: 10px;
    font-size: 11px;
  }

  .hero-actions {
    margin-top: 8px;
  }

  .hero-button {
    min-height: 40px;
  }

  .hero-portrait {
    right: -10px;
    width: min(40vw, 338px);
  }

  .hero-tools {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    margin: 6px 18px 10px;
    transform: none;
  }

  .hero-tools .home-tool,
  .hero-tools .home-tool:nth-child(2n),
  .hero-tools .home-tool:last-child {
    flex-basis: 40%;
    min-height: 58px;
  }
}
