/* ==========================================
   DeepTora Contact Page Styles
   ========================================== */

/* ---------- Page tokens (scoped to this page only) ---------- */
body.contact-page {
  --field-bg: rgba(118, 118, 128, 0.12);
  --field-bg-focus: #ffffff;
  --field-border: rgba(60, 60, 67, 0.08);
  --placeholder: rgba(60, 60, 67, 0.55);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] body.contact-page {
  --field-bg: rgba(255, 255, 255, 0.08);
  --field-bg-focus: rgba(255, 255, 255, 0.13);
  --field-border: rgba(255, 255, 255, 0.1);
  --placeholder: rgba(235, 235, 245, 0.45);
}

/* ---------- Pure white page background (light theme) ---------- */
html[data-theme="light"],
html[data-theme="light"] body.contact-page {
  background: #ffffff;
}

html[data-theme="light"] body.contact-page main.container {
  background: transparent;
}

/* ---------- Background image (laptops & desktops, 1024px+) ----------
   A fixed full-screen photo layer sits behind the page content, covered by a
   soft wash (denser on the left where the heading is) so text stays readable.
   The form itself sits on a frosted-glass panel (see the desktop block below).
   Tablets and phones keep the clean white page. */
@media (min-width: 1024px) {
  body.contact-page {
    isolation: isolate; /* keeps the background layer behind content but above the page color */
  }

  body.contact-page main.container {
    background: transparent;
  }

  body.contact-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
      linear-gradient(90deg,
        rgba(255, 255, 255, 0.93) 0%,
        rgba(255, 255, 255, 0.84) 45%,
        rgba(255, 255, 255, 0.62) 100%),
      url('../images/contact_us_bg.jpg');
    background-size: cover;
    background-position: 72% 40%;
    background-repeat: no-repeat;
  }

  html[data-theme="dark"] body.contact-page::before {
    background-image:
      linear-gradient(90deg,
        rgba(10, 10, 12, 0.92) 0%,
        rgba(10, 10, 12, 0.84) 45%,
        rgba(10, 10, 12, 0.62) 100%),
      url('../images/contact_us_bg.jpg');
  }
}

/* Layout wrapper: stacked (plain block) by default for phones & tablets */
.contact-layout {
  display: block;
  width: 100%;
}

/* ---------- Heading typography (Apple-style scale) ---------- */
body.contact-page .contact-layout .header-section h1 {
  display: block;
  margin: 0;
  padding: 0;
  text-align: left;
  line-height: 1.08;
}

body.contact-page .contact-layout .header-section h1 .h1-primary {
  display: block;
  width: auto;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.08;
  text-align: left;
  color: var(--text-primary);
}

body.contact-page .contact-layout .header-section h1 .h1-secondary {
  display: block;
  width: auto;
  margin: 8px 0 0;
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-align: left;
  color: var(--text-secondary, #6e6e73);
}

body.contact-page .contact-layout .header-section .subtitle {
  width: auto;
  margin: 20px 0 0;
  font-size: 1.0625rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.47;
  text-align: left;
  color: var(--text-secondary, #6e6e73);
  text-wrap: pretty;
}

/* ---------- Card ---------- */
.contact-card {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 767px) {
  .contact-card {
    padding: 24px 20px;
  }
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  transition: opacity 0.35s var(--ease-out),
              transform 0.35s var(--ease-out),
              filter 0.35s var(--ease-out);
}

.contact-form.is-leaving {
  opacity: 0;
  transform: scale(0.97) translateY(-6px);
  filter: blur(4px);
  pointer-events: none;
}

.contact-form.is-hidden {
  display: none;
}

.contact-form.is-entering {
  animation: formIn 0.5s var(--ease-out) both;
}

@keyframes formIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ---------- Apple-style fields ---------- */
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 15px 16px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: 14px;
  outline: none;
  box-shadow: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--placeholder, var(--text-muted));
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: var(--border-subtle, rgba(0, 0, 0, 0.08));
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: var(--field-bg-focus);
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  padding-right: 44px;
  cursor: pointer;
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

/* Live character counter under the message box */
.char-counter {
  align-self: flex-end;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

.char-counter.near-limit {
  color: var(--accent-red, #ff3b30);
}

/* Submit Button with Spring Physics */
.contact-form button[type="submit"] {
  width: 100%;
  padding: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--accent-blue);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 102, 204, 0.25);
  transform: translateZ(0);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, box-shadow;
  margin-top: 8px;
}

.contact-form button[type="submit"]:hover {
  background-color: var(--accent-blue-hover);
  transform: translateY(-2px) scale(1.008);
  box-shadow: 0 8px 24px rgba(0, 102, 204, 0.35);
}

.contact-form button[type="submit"]:active {
  transform: translateY(1px) scale(0.965);
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
}

.contact-form button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
  display: none;
}

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

.form-status-box {
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  display: none;
  text-align: center;
  word-break: break-word;
}

.form-status-box.success {
  background-color: rgba(52, 199, 89, 0.12);
  border: 1px solid rgba(52, 199, 89, 0.3);
  color: var(--accent-green, #34c759);
  display: block;
}

.form-status-box.error {
  background-color: rgba(255, 59, 48, 0.12);
  border: 1px solid rgba(255, 59, 48, 0.3);
  color: var(--accent-red, #ff3b30);
  display: block;
}

/* ==========================================
   SUCCESS VIEW (green checkmark)
   ========================================== */
.success-view {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  width: 100%;
  min-height: 320px;
}

.success-view.is-active {
  display: flex;
}

.success-badge {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--accent-green, #34c759);
  box-shadow: 0 10px 30px rgba(52, 199, 89, 0.35);
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.4);
}

.success-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-green, #34c759);
  opacity: 0;
  pointer-events: none;
}

.success-svg {
  width: 46px;
  height: 46px;
  overflow: visible;
}

.check-mark {
  fill: none;
  stroke: #ffffff;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
}

.success-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  outline: none;
  opacity: 0;
  transform: translateY(12px);
}

.success-text {
  margin: 0;
  max-width: 320px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-secondary, #6e6e73);
  opacity: 0;
  transform: translateY(12px);
}

.success-again {
  margin-top: 12px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-blue);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  transition: background-color 0.2s ease, transform 0.3s var(--ease-spring);
}

.success-again:hover {
  background-color: rgba(0, 113, 227, 0.08);
}

.success-again:active {
  transform: scale(0.96);
}

.success-again:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

/* Animation sequence: badge pops -> ring ripples -> check draws -> text rises */
.success-view.is-visible .success-badge {
  animation: badgePop 0.7s var(--ease-spring) forwards;
}

.success-view.is-visible .success-badge::after {
  animation: badgeRipple 1s ease-out 0.3s forwards;
}

.success-view.is-visible .check-mark {
  animation: drawCheck 0.5s var(--ease-out) 0.4s forwards;
}

.success-view.is-visible .success-title {
  animation: riseIn 0.6s var(--ease-out) 0.55s forwards;
}

.success-view.is-visible .success-text {
  animation: riseIn 0.6s var(--ease-out) 0.68s forwards;
}

.success-view.is-visible .success-again {
  animation: riseIn 0.6s var(--ease-out) 0.85s forwards;
}

@keyframes badgePop {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes badgeRipple {
  0%   { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0;    transform: scale(1.7); }
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Respect reduced-motion preferences: show final state, no movement */
@media (prefers-reduced-motion: reduce) {
  .contact-form,
  .contact-form.is-leaving {
    transition: none;
    filter: none;
    transform: none;
  }

  .contact-form.is-entering {
    animation: none;
  }

  .success-view .success-badge,
  .success-view .success-title,
  .success-view .success-text,
  .success-view .success-again {
    opacity: 1;
    transform: none;
    animation: none !important;
  }

  .success-view .success-badge::after {
    display: none;
  }

  .success-view .check-mark {
    stroke-dashoffset: 0;
    animation: none !important;
  }
}

/* ==========================================
   LARGE SCREENS (laptops & desktops, 1024px+)
   Heading on the left, form on the right,
   no card background. Tablets/phones unchanged.
   ========================================== */
@media (min-width: 1024px) {

  /* Allow the page container to be wide enough for two columns */
  #mainContainer.container {
    max-width: 1180px;
    width: 100%;
  }

  .contact-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 540px);
    column-gap: 80px;
    align-items: center;
    margin: 0 auto;
    padding-block: clamp(16px, 4vh, 56px);
  }

  /* Left column: heading + subtitle, all starting from the same left edge */
  body.contact-page .contact-layout .header-section {
    display: block;
    text-align: left;
    margin: 0;
    padding: 0;
    max-width: none;
  }

  body.contact-page .contact-layout .header-section h1 {
    display: block;
    align-items: flex-start;
    margin: 0;
    text-align: left;
  }

  body.contact-page .contact-layout .header-section h1 .h1-primary,
  body.contact-page .contact-layout .header-section h1 .h1-secondary {
    display: block;
    margin-left: 0;
    margin-right: 0;
    text-align: left;
  }

  body.contact-page .contact-layout .header-section .subtitle {
    margin: 20px 0 0;
    max-width: 420px;
    text-align: left;
  }

  /* Right column: form on a frosted-glass panel (Apple "material") */
  .contact-layout .contact-card.glass-card {
    max-width: 100%;
    margin: 0;
    padding: 32px 32px 28px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 28px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.7),
      0 2px 8px rgba(0, 0, 0, 0.04),
      0 24px 60px rgba(0, 0, 0, 0.12);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    transform: none;
  }

  html[data-theme="dark"] .contact-layout .contact-card.glass-card {
    background: rgba(28, 28, 30, 0.62);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 24px 60px rgba(0, 0, 0, 0.5);
  }

  /* Browsers without backdrop-filter: use a more opaque panel */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .contact-layout .contact-card.glass-card {
      background: rgba(255, 255, 255, 0.94);
    }

    html[data-theme="dark"] .contact-layout .contact-card.glass-card {
      background: rgba(28, 28, 30, 0.94);
    }
  }

  .contact-layout .contact-card.glass-card::before,
  .contact-layout .contact-card.glass-card::after {
    content: none;
  }

  /* Compact spacing so the whole form fits without scrolling */
  .contact-form {
    gap: 16px;
  }

  .form-group {
    gap: 6px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 14px 16px;
  }

  .form-group select {
    padding-right: 44px;
  }

  .form-group textarea {
    min-height: 130px;
  }

  .contact-form button[type="submit"] {
    padding: 15px;
    margin-top: 4px;
  }
}

/* Short laptop screens: tighten a little more */
@media (min-width: 1024px) and (max-height: 800px) {
  .contact-layout .contact-card.glass-card {
    padding: 24px 28px 22px;
    border-radius: 24px;
  }

  .contact-form {
    gap: 12px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 12px 14px;
  }

  .form-group textarea {
    min-height: 100px;
  }

  .contact-form button[type="submit"] {
    padding: 13px;
  }
}