/* ==================================================================
   Badriyya Grand 50 — Profile Frame Generator
   Palette and type match jamiabadriya.com (Fraunces + Inter).
   Mobile-first; desktop layout from 900px.
   ================================================================== */

:root {
  --c-emerald: #103F34;
  --c-forest: #174C3E;
  --c-gold: #C5A36A;
  --c-gold-soft: #E3C891;
  --c-gold-ink: #7A5C26;
  --c-gold-tint: #EFE6D2;
  --c-ivory: #F7F5EE;
  --c-ivory-deep: #EEEADC;
  --c-sand: #E6E0CF;
  --c-charcoal: #1B2824;
  --c-muted: #4A5752;
  --c-white: #FFFFFF;
  --c-error: #9B2C2C;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --shadow-card: 0 1px 2px rgb(16 63 52 / .06), 0 18px 50px -24px rgb(16 63 52 / .35);
  --shadow-btn: 0 10px 24px -12px rgb(16 63 52 / .55);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --gutter: clamp(16px, 4vw, 32px);
}

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font: 400 1rem/1.6 var(--font-body);
  color: var(--c-charcoal);
  background: var(--c-ivory);
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 500; color: var(--c-emerald); line-height: 1.2; text-wrap: balance; }
p { margin: 0; }
a { color: var(--c-forest); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-gold); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

svg[viewBox="0 0 24 24"] {
  width: 1.2em; height: 1.2em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: var(--gutter); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  padding: .6rem 1rem; border-radius: var(--r-sm);
  background: var(--c-emerald); color: var(--c-white); text-decoration: none;
}
.skip-link:focus { top: 12px; }

.eyebrow {
  font-size: .75rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--c-gold-ink);
}
.eyebrow--center { text-align: center; }

/* ------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--c-white); --btn-fg: var(--c-emerald);
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 48px; padding: .75rem 1.4rem;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font: 600 .95rem/1.2 var(--font-body); letter-spacing: .01em;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease), transform .15s var(--ease), opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn--lg { min-height: 56px; padding: 1rem 1.8rem; font-size: 1.02rem; }
.btn--block { display: flex; width: 100%; }

.btn--primary { --btn-bg: var(--c-emerald); --btn-fg: var(--c-white); box-shadow: var(--shadow-btn); }
.btn--primary:hover:not(:disabled) { --btn-bg: var(--c-forest); }

.btn--gold {
  --btn-bg: linear-gradient(180deg, #D4B47C, var(--c-gold));
  background: linear-gradient(180deg, #D7B982 0%, var(--c-gold) 100%);
  color: #2A1F0B;
  box-shadow: 0 12px 28px -14px rgb(122 92 38 / .8), inset 0 1px 0 rgb(255 255 255 / .35);
}
.btn--gold:hover:not(:disabled) { background: linear-gradient(180deg, #E0C48F 0%, #CDAD74 100%); }
.btn--gold.is-busy { cursor: progress; }

.btn--ghost { --btn-bg: transparent; --btn-fg: var(--c-emerald); border-color: rgb(16 63 52 / .22); }
.btn--ghost:hover:not(:disabled) { --btn-bg: rgb(16 63 52 / .05); }

.btn--light { --btn-bg: var(--c-ivory); --btn-fg: var(--c-emerald); }
.btn--light:hover { --btn-bg: var(--c-white); }
.btn--outline-light { --btn-bg: transparent; --btn-fg: var(--c-ivory); border-color: rgb(227 200 145 / .55); }
.btn--outline-light:hover { --btn-bg: rgb(255 255 255 / .08); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 1px solid rgb(16 63 52 / .18); border-radius: 50%;
  background: var(--c-white); color: var(--c-emerald); cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--c-ivory); border-color: rgb(16 63 52 / .35); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ------------------------------------------------------------ header */
.site-header {
  position: relative; z-index: 2;
  border-bottom: 1px solid rgb(16 63 52 / .08);
  background: rgb(247 245 238 / .9);
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 68px; padding-block: 8px; }
.brand { display: block; }
.brand img { width: auto; height: 44px; }
.site-header__link {
  font-size: .85rem; font-weight: 500; text-decoration: none; color: var(--c-forest);
  padding: .4rem .2rem; border-bottom: 1px solid rgb(197 163 106 / .6);
}
.site-header__link:hover { color: var(--c-emerald); border-bottom-color: var(--c-gold); }

/* ------------------------------------------------------------ hero */
.hero {
  position: relative; overflow: hidden;
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(4.5rem, 9vw, 6.5rem);
  text-align: center;
  background:
    radial-gradient(60rem 30rem at 50% -10%, rgb(227 200 145 / .28), transparent 60%),
    radial-gradient(40rem 22rem at 100% 100%, rgb(23 76 62 / .08), transparent 70%),
    var(--c-ivory);
}
/* Fine double rule — a quiet ceremonial accent. */
.hero__inner::after {
  content: ""; width: 120px; height: 7px; margin-top: 1.4rem;
  border-block: 1px solid var(--c-gold);
}
.hero__inner { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; max-width: 760px; }
.hero__title { display: flex; flex-direction: column; gap: .35rem; }
.hero__logo { width: min(100%, 560px); height: auto; margin: .2rem auto .6rem; }
.hero__brand {
  font-size: clamp(2.3rem, 1.4rem + 4.4vw, 4.2rem); font-weight: 500; letter-spacing: -.01em;
  color: var(--c-emerald);
}
.hero__sub {
  font-size: clamp(1.15rem, 1rem + .9vw, 1.6rem); font-weight: 400; font-style: italic;
  color: var(--c-gold-ink);
}
.hero__lead { max-width: 36rem; font-size: clamp(1rem, .95rem + .25vw, 1.1rem); color: var(--c-muted); }
.hero .btn { margin-top: .6rem; }

/* ------------------------------------------------------------ generator */
.generator { position: relative; z-index: 1; margin-top: clamp(-3.5rem, -6vw, -2.5rem); padding-bottom: clamp(3rem, 7vw, 5rem); scroll-margin-top: 12px; outline: none; }

.card {
  background: var(--c-white);
  border: 1px solid rgb(197 163 106 / .35);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.gen { display: grid; gap: 1.25rem; padding: 12px; }

/* --- preview stage --- */
.stage {
  position: relative; width: 100%; max-width: 560px; margin-inline: auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md); overflow: hidden;
  background: var(--c-ivory-deep);
  box-shadow: inset 0 0 0 1px rgb(16 63 52 / .08);
}
.stage__canvas {
  width: 100%; height: 100%;
  touch-action: none;                  /* we handle drag & pinch ourselves */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  opacity: 0; transition: opacity .4s var(--ease);
}
.stage.is-ready .stage__canvas { opacity: 1; }
.stage.has-photo .stage__canvas { cursor: grab; }
.stage.is-dragging .stage__canvas { cursor: grabbing; }
.stage.is-dropping { box-shadow: inset 0 0 0 3px var(--c-gold); }
.stage__canvas:focus-visible { outline: 3px solid var(--c-gold); outline-offset: -3px; border-radius: var(--r-md); }

/* Empty-state button sits exactly over the circular photo window
   (window centre 653,652 / r 404 in a 1350px frame → percentages). */
.stage__empty {
  position: absolute;
  left: 18.4%; top: 18.4%; width: 59.85%; height: 59.85%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  padding: 1rem; border: 0; border-radius: 50%;
  background: transparent; color: var(--c-emerald); cursor: pointer;
  transition: background-color .25s var(--ease);
}
.stage__empty:hover { background: rgb(255 255 255 / .25); }
.stage__empty:focus-visible { outline-offset: -6px; border-radius: 50%; }
.stage__empty-icon {
  display: grid; place-items: center; width: clamp(48px, 13vw, 64px); aspect-ratio: 1;
  border-radius: 50%; background: var(--c-emerald); color: var(--c-white);
  box-shadow: 0 10px 24px -10px rgb(16 63 52 / .7);
  font-size: clamp(1.2rem, 3.6vw, 1.5rem);
}
.stage__empty-title { margin-top: .35rem; font-family: var(--font-display); font-size: clamp(1.05rem, .9rem + 1vw, 1.35rem); font-weight: 500; }
.stage__empty-hint { font-size: clamp(.72rem, .68rem + .2vw, .82rem); color: var(--c-muted); }

.stage__loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem;
  background: rgb(247 245 238 / .82); color: var(--c-emerald); font-weight: 500;
  backdrop-filter: blur(2px);
}
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgb(16 63 52 / .15); border-top-color: var(--c-emerald);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage__gesture {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  padding: .4rem .85rem; border-radius: var(--r-pill);
  background: rgb(16 63 52 / .86); color: var(--c-white);
  font-size: .78rem; white-space: nowrap; pointer-events: none;
  animation: fadeUp .35s var(--ease);
}
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 6px); } }

/* --- control panel --- */
.gen__panel { display: flex; flex-direction: column; gap: 1rem; padding: .5rem .5rem 1rem; }
.panel-head__title { font-size: 1.35rem; }
.panel-head__text { margin-top: .25rem; font-size: .92rem; color: var(--c-muted); }

.msg { padding: .7rem .9rem; border-radius: var(--r-sm); font-size: .9rem; }
.msg--error { background: #FBEDEA; color: var(--c-error); border: 1px solid #F0CFC8; }

.controls { margin: 0; padding: 1rem; border: 1px solid var(--c-sand); border-radius: var(--r-md); background: var(--c-ivory); min-width: 0; }
.controls:disabled { opacity: .55; }
.controls__legend { padding: 0 .4rem; font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--c-gold-ink); }

.zoom__label { display: block; margin-bottom: .35rem; font-size: .85rem; font-weight: 500; }
.zoom__row { display: flex; align-items: center; gap: .6rem; }

/* range slider */
input[type="range"] {
  flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
input[type="range"]:disabled { cursor: not-allowed; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--c-gold), var(--c-emerald)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--c-gold), var(--c-emerald)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%;
  background: var(--c-white); border: 2px solid var(--c-emerald); box-shadow: 0 2px 6px rgb(16 63 52 / .3);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-white); border: 2px solid var(--c-emerald); box-shadow: 0 2px 6px rgb(16 63 52 / .3);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--c-gold); outline-offset: 2px; }
input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--c-gold); outline-offset: 2px; }

.tool-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  min-height: 64px; padding: .6rem .3rem;
  border: 1px solid rgb(16 63 52 / .14); border-radius: var(--r-sm);
  background: var(--c-white); color: var(--c-emerald); cursor: pointer;
  font-size: .78rem; font-weight: 500;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.tool svg { font-size: 1.15rem; }
.tool:hover:not(:disabled) { border-color: rgb(16 63 52 / .32); background: var(--c-gold-tint); }
.tool:disabled { cursor: not-allowed; }

.privacy {
  display: flex; gap: .55rem; align-items: flex-start;
  font-size: .82rem; color: var(--c-muted);
}
.privacy svg { margin-top: .1rem; color: var(--c-forest); }

/* ------------------------------------------------------------ steps */
.steps { padding-block: clamp(3rem, 7vw, 5rem); background: var(--c-white); border-block: 1px solid rgb(197 163 106 / .25); }
.section-title { margin-top: .5rem; text-align: center; font-size: clamp(1.7rem, 1.3rem + 1.8vw, 2.4rem); }
.steps__list { display: grid; gap: 1rem; margin: 2rem 0 0; padding: 0; list-style: none; }
.step {
  display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; row-gap: .2rem; align-items: start;
  padding: 1.25rem; border-radius: var(--r-md); background: var(--c-ivory); border: 1px solid var(--c-sand);
}
.step__num {
  grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--c-gold); color: var(--c-gold-ink);
  font-family: var(--font-display); font-size: 1.25rem;
}
.step__title { font-size: 1.12rem; }
.step__text { font-size: .93rem; color: var(--c-muted); }

/* ------------------------------------------------------------ share band */
.share {
  padding-block: clamp(3rem, 7vw, 4.5rem); text-align: center; color: var(--c-ivory);
  background:
    radial-gradient(40rem 20rem at 50% 0%, rgb(197 163 106 / .22), transparent 70%),
    var(--c-emerald);
}
.share__inner { display: flex; flex-direction: column; align-items: center; gap: 1rem; max-width: 760px; }
.share__title { color: var(--c-white); font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); }
.share__text { max-width: 34rem; color: #D6DDD9; }
.share__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .65rem; margin-top: .5rem; }

/* ------------------------------------------------------------ footer */
.site-footer { padding-block: 2.5rem calc(2rem + env(safe-area-inset-bottom)); background: #0B2E26; color: #C9D2CD; text-align: center; }
.site-footer__inner { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.site-footer__name { font-family: var(--font-display); font-size: 1.2rem; color: var(--c-white); }
.site-footer__place { font-size: .9rem; }
.site-footer__links { display: flex; gap: .5rem; margin-top: .6rem; font-size: .88rem; }
.site-footer__links a { color: var(--c-gold-soft); text-decoration: none; }
.site-footer__links a:hover { text-decoration: underline; }
.site-footer__copy { margin-top: .9rem; font-size: .8rem; color: #9FB0A8; }

/* inProQs studio signature (standard spec) */
.footer-credit {
  display: inline-flex; align-items: baseline; gap: .28em; margin-top: .35rem;
  font-size: .78rem; color: #9FB0A8; text-decoration: none;
  transition: color .2s var(--ease);
}
.footer-credit__an { font-weight: 400; }
.footer-credit__brand { font-weight: 700; color: #C9D2CD; transition: color .2s var(--ease); }
.footer-credit__creation { font-size: .92em; font-weight: 300; }
.footer-credit__arrow { width: .95em !important; height: .95em !important; align-self: center; transition: transform .2s var(--ease); }
.footer-credit:hover, .footer-credit:focus-visible { color: var(--c-gold-soft); }
.footer-credit:hover .footer-credit__brand, .footer-credit:focus-visible .footer-credit__brand { color: var(--c-gold-soft); }
.footer-credit:hover .footer-credit__arrow { transform: translate(2px, -2px); }

/* ------------------------------------------------------------ result dialog */
.result {
  width: min(480px, calc(100% - 2 * 16px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--c-white); color: var(--c-charcoal);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .45);
}
.result::backdrop { background: rgb(11 46 38 / .6); backdrop-filter: blur(3px); }
.result[open] { animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.result__body { position: relative; display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem; }
.result__close { position: absolute; top: 10px; right: 10px; }
.result__title { padding-right: 3rem; font-size: 1.35rem; }
.result__img { width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--c-sand); -webkit-touch-callout: default; }
.result__hint { font-size: .92rem; color: var(--c-muted); }
.result__fallback { display: block; margin-top: .3rem; font-size: .82rem; }
.result__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.result__actions .btn { flex: 1 1 auto; }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 100;
  max-width: calc(100% - 32px); padding: .75rem 1.1rem; border-radius: var(--r-pill);
  background: var(--c-emerald); color: var(--c-white); font-size: .9rem; font-weight: 500;
  box-shadow: 0 14px 30px -12px rgb(0 0 0 / .45);
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

/* ------------------------------------------------------------ larger screens */
@media (min-width: 640px) {
  .gen { padding: 18px; }
  .steps__list { grid-template-columns: repeat(3, 1fr); }
  .step { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 1.75rem 1.25rem; }
  .step__num { grid-row: auto; margin-bottom: .6rem; }
}

@media (min-width: 900px) {
  .brand img { height: 48px; }
  .gen { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 2rem; padding: 24px; align-items: center; }
  .gen__panel { padding: 1rem 1rem 1rem 0; }
}

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