:root {
  color-scheme: light;
  font-family: "Tajawal", sans-serif;
  --hamad-ink: #102f3a;
  --hamad-teal: #0b6570;
  --hamad-gold: #c8943c;
  --hamad-paper: #fffdf7;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #1f86bb;
  color: var(--hamad-ink);
}

.hamad-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: linear-gradient(145deg, #167eaf, #1f96cc 55%, #7dc8df);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.hamad-loader__mark {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hamad-loader-spin 800ms linear infinite;
}

body.is-ready .hamad-loader {
  visibility: hidden;
  opacity: 0;
}

button,
input,
textarea {
  font: inherit;
}

.hamad-scene {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background-image: url("assets/haj-hamad-bg.webp");
  background-position: center center;
  background-size: cover;
  opacity: 0;
  transform: scale(1.008);
  transition: opacity 320ms ease, transform 500ms ease;
}

body.is-ready .hamad-scene {
  opacity: 1;
  transform: none;
}

.hamad-shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(5, 28, 37, 0.12);
}

.hamad-header {
  position: absolute;
  inset: 22px 28px auto;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hamad-header h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  letter-spacing: 0;
  text-shadow: 0 2px 12px rgba(4, 24, 31, 0.42);
}

.hamad-back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 6px;
  background: rgba(9, 53, 64, 0.68);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

.hamad-back span:first-child {
  font-size: 1.25rem;
}

.hamad-character {
  position: absolute;
  right: clamp(4%, 7vw, 10%);
  bottom: -3%;
  z-index: 2;
  width: auto;
  height: min(91dvh, 980px);
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 18px 24px rgba(18, 38, 45, 0.25));
  animation: hamad-breathe 4.6s ease-in-out infinite;
}

.hamad-dialogue-wrap {
  position: absolute;
  top: 19%;
  right: clamp(42%, 47vw, 53%);
  z-index: 3;
  width: min(430px, 38vw);
}

.hamad-dialogue {
  position: relative;
  width: 100%;
  min-height: 176px;
  padding: 24px 26px 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 18px 52px rgba(8, 36, 44, 0.22);
  color: var(--hamad-ink);
  text-align: right;
  transition: transform 180ms ease, opacity 150ms ease;
  backdrop-filter: blur(9px);
}

.hamad-dialogue::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: 34px;
  width: 34px;
  height: 34px;
  background: rgba(255, 253, 247, 0.94);
  clip-path: polygon(0 0, 0 100%, 100% 70%);
}

.hamad-dialogue:hover,
.hamad-dialogue:focus-within {
  transform: translateY(-3px);
  outline: 3px solid rgba(200, 148, 60, 0.5);
  outline-offset: 3px;
}

.hamad-dialogue.is-changing {
  opacity: 0;
  transform: translateY(5px);
}

.hamad-dialogue__text {
  display: block;
  min-height: 84px;
  font-size: clamp(1.08rem, 1.8vw, 1.38rem);
  font-weight: 700;
  line-height: 1.85;
}

.hamad-dialogue__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  color: #557078;
  font-size: 0.88rem;
  font-weight: 700;
}

.hamad-dialogue__controls {
  display: inline-flex;
  direction: ltr;
  gap: 8px;
}

.hamad-nav {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--hamad-gold);
  color: #201603;
  cursor: pointer;
  font-size: 1.15rem;
  transition: transform 150ms ease, opacity 150ms ease;
}

.hamad-nav:hover:not(:disabled),
.hamad-nav:focus-visible {
  transform: scale(1.08);
  outline: 3px solid rgba(200, 148, 60, 0.35);
  outline-offset: 2px;
}

.hamad-nav:disabled {
  cursor: default;
  opacity: 0.32;
}

.hamad-modal[hidden] {
  display: none;
}

.hamad-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 25, 31, 0.72);
  overflow-y: auto;
}

.hamad-modal__panel {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100dvh - 40px);
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid rgba(200, 148, 60, 0.5);
  border-radius: 8px;
  background: var(--hamad-paper);
  box-shadow: 0 26px 70px rgba(2, 18, 23, 0.38);
  overflow-y: auto;
}

.hamad-modal__close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #e9eee9;
  color: var(--hamad-ink);
  cursor: pointer;
  font-size: 1.5rem;
}

.hamad-modal__eyebrow {
  margin: 0 0 5px;
  color: var(--hamad-teal);
  font-weight: 800;
}

.hamad-modal h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  letter-spacing: 0;
}

.hamad-modal__intro {
  margin: 10px 0 22px;
  color: #52666c;
  line-height: 1.75;
}

.hamad-request-form {
  display: grid;
  gap: 15px;
}

.hamad-request-form label {
  display: grid;
  gap: 7px;
  color: var(--hamad-ink);
  font-weight: 800;
}

.hamad-request-form input,
.hamad-request-form textarea {
  width: 100%;
  border: 1px solid #b8c7c8;
  border-radius: 6px;
  background: #fff;
  color: var(--hamad-ink);
  padding: 12px 14px;
  outline: 0;
}

.hamad-request-form input:focus,
.hamad-request-form textarea:focus {
  border-color: var(--hamad-teal);
  box-shadow: 0 0 0 3px rgba(11, 101, 112, 0.14);
}

.hamad-request-form textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.7;
}

.hamad-honeypot {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
}

.hamad-response-note {
  margin: 0;
  padding: 12px 14px;
  border-right: 4px solid var(--hamad-gold);
  background: #f5ecd9;
  color: #4d3b18;
  line-height: 1.65;
  font-weight: 700;
}

.hamad-form-status {
  min-height: 24px;
  margin: 0;
  color: #a22a1d;
  font-weight: 700;
}

.hamad-submit {
  min-height: 50px;
  border: 0;
  border-radius: 6px;
  background: var(--hamad-teal);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.hamad-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.hamad-success {
  padding: 22px 0;
  text-align: center;
}

.hamad-success__mark {
  display: inline-grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 50%;
  background: #dbeee5;
  color: #167347;
  font-size: 2rem;
  font-weight: 800;
}

.hamad-success p {
  color: #52666c;
  line-height: 1.8;
}

.hamad-success a {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  margin-top: 10px;
  padding: 0 20px;
  border-radius: 6px;
  background: var(--hamad-teal);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

@keyframes hamad-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes hamad-loader-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 760px) {
  .hamad-scene {
    background-image: url("assets/haj-hamad-bg-mobile.webp");
    background-position: center center;
  }

  .hamad-shade {
    background: rgba(6, 32, 40, 0.13);
  }

  .hamad-header {
    inset: 12px 12px auto;
  }

  .hamad-header h1 {
    font-size: 1.12rem;
  }

  .hamad-back {
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.84rem;
  }

  .hamad-character {
    right: -12vw;
    bottom: -1%;
    height: min(64dvh, 650px);
  }

  .hamad-dialogue-wrap {
    top: 15%;
    right: 16px;
    left: 16px;
    width: auto;
  }

  .hamad-dialogue {
    min-height: 148px;
    padding: 18px 18px 14px;
  }

  .hamad-dialogue::after {
    right: auto;
    left: 22%;
    bottom: -22px;
    transform: rotate(90deg);
  }

  .hamad-dialogue__text {
    min-height: 70px;
    font-size: 1rem;
    line-height: 1.75;
  }

  .hamad-modal {
    align-items: end;
    padding: 12px;
  }

  .hamad-modal__panel {
    max-height: calc(100dvh - 24px);
    padding: 28px 18px 22px;
  }

  .hamad-request-form textarea {
    min-height: 150px;
  }
}

@media (max-height: 760px) and (min-width: 761px) {
  .hamad-modal__panel {
    padding: 22px 34px;
  }

  .hamad-modal__intro {
    margin: 6px 0 12px;
  }

  .hamad-request-form {
    gap: 9px;
  }

  .hamad-request-form input,
  .hamad-request-form textarea {
    padding: 9px 12px;
  }

  .hamad-request-form textarea {
    min-height: 112px;
  }

  .hamad-response-note {
    padding: 9px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hamad-loader,
  .hamad-scene,
  .hamad-nav {
    transition: none;
  }

  .hamad-loader__mark {
    animation-duration: 1.5s;
  }

  .hamad-character {
    animation: none;
  }

  .hamad-dialogue {
    transition: none;
  }
}
