/* ==========================================================
   TraceTheSource — style.css
   Two-mode layout:
   - Landing mode: big hero + big search (~3/4 up page)
   - Results mode: topbar appears, hero collapses, results show
========================================================== */

:root{
  --bg0:#030712;
  --bg1:#020617;
  --panel: rgba(10, 18, 40, .55);
  --panel2: rgba(10, 18, 40, .70);
  --stroke: rgba(148, 163, 184, .20);
  --stroke2: rgba(148, 163, 184, .32);
  --text:#e5e7eb;
  --muted:#9ca3af;

  --accent:#60a5fa;
  --accent2:#22d3ee;

  --shadow: 0 22px 60px rgba(0,0,0,.55);
  --shadow2: 0 10px 30px rgba(0,0,0,.35);

  --radius: 18px;
  --radius2: 999px;

  --topbarH: 68px;
}

*{ box-sizing:border-box; }

/* ==========================================================
   iOS / Safari FIXES (prevents "giant text" + broken layout)
========================================================== */
html{
  height:100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body{
  height:100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body{
  margin:0;
  font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(900px 520px at 20% 10%, rgba(96,165,250,.22), transparent 60%),
    radial-gradient(900px 520px at 80% 20%, rgba(34,211,238,.14), transparent 55%),
    radial-gradient(1000px 700px at 50% 90%, rgba(99,102,241,.10), transparent 60%),
    linear-gradient(180deg, var(--bg1), #000);
}

/* Utilities */
.hidden{ display:none !important; }
.muted{ color:var(--muted); }

/* Page wrapper */
.page{
  min-height:100vh;
}

/* ==========================================================
   TOPBAR (results mode only)
========================================================== */

.topbar{
  position: sticky;
  top:0;
  z-index:50;
  height: var(--topbarH);
  display:flex;
  align-items:center;

  background: rgba(2, 6, 23, .55);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(148,163,184,.12);

  transition: opacity .18s ease, transform .18s ease;
}

.topbar-inner{
  width:min(1100px, calc(100% - 32px));
  margin:0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
}

.topbar[aria-hidden="true"]{
  opacity:0;
  transform: translateY(-10px);
  pointer-events:none;
}

.logo{
  display:inline-flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  color:var(--text);
  font-weight:650;
  letter-spacing:.2px;
  white-space:nowrap;
}

.logo-dot{
  width:10px;height:10px;border-radius:999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 0 3px rgba(96,165,250,.12);
}

/* ==========================================================
   HERO
========================================================== */

.hero{
  position: relative;
  overflow:hidden;
  padding: 26px 0 64px;
}

.hero::before{
  content:"";
  position:absolute; inset:-40px;
  background:
    radial-gradient(800px 520px at 50% 25%, rgba(0,0,0,.25), transparent 60%),
    radial-gradient(1200px 800px at 50% 0%, rgba(0,0,0,.35), transparent 70%);
  pointer-events:none;
}

.hero-inner{
  position: relative;
  width:min(1100px, calc(100% - 32px));
  margin:0 auto;
  min-height: calc(100vh - 90px);
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  align-items:center;
  text-align:center;
  padding-top: 18vh;
  gap: 20px;
}

.brand-title{
  margin:0;
  font-size: clamp(40px, 4.6vw, 64px);
  letter-spacing: .5px;
}

.brand-subtitle{
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 640px;
}

/* ==========================================================
   SEARCH
========================================================== */

.search{
  width:100%;
  display:flex;
  flex-direction: column;
  align-items:center;
  gap: 8px;
}

/* Base searchbox */
.searchbox{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px;
  border-radius: var(--radius2);
  border: 1px solid var(--stroke);
  background: rgba(2, 6, 23, .50);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow2);
}

.search--hero .searchbox{
  width:100%;
}

.search--compact .searchbox{
  width: min(640px, 62vw);
  padding: 8px;
}

.searchbox input{
  width:100%;
  border:none;
  outline:none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
}

.searchbox input[type="search"]::-webkit-search-cancel-button{
  -webkit-appearance:none;
  appearance:none;
  display:none;
}

.searchbox input::placeholder{
  color: rgba(156,163,175,.78);
}

.searchbox--hero{
  padding: 12px;
}

.searchbox--hero input{
  font-size: 17px;
  padding: 14px 16px;
}

.search--compact .searchbox input{
  font-size: 14px;
  padding: 10px 12px;
}

/* Clear (X) button */
.clear-btn{
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(2, 6, 23, .30);
  color: rgba(229,231,235,.90);
  cursor: pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.clear-btn:hover{
  transform: translateY(-1px);
  background: rgba(2, 6, 23, .42);
  border-color: rgba(148,163,184,.28);
}

.clear-btn:active{
  transform: translateY(0px);
}

.clear-btn.hidden{
  display:none !important;
}

.clear-btn::before{
  content:"×";
  font-size: 22px;
  line-height: 1;
  margin-top: -1px;
}

/* Hint */
.hint{
  color: rgba(229,231,235,.88);
  font-size: 13px;
  margin-top: 0;
  text-align:center;
}

/* ==========================================================
   STATUS
========================================================== */

.status{
  width:100%;
  padding: 10px 14px;
  border-radius: var(--radius2);
  border: 1px solid var(--stroke2);
  background: rgba(2, 6, 23, .55);
  color: var(--text);
  box-shadow: var(--shadow2);
}

.status--ok{ border-color: rgba(34,197,94,.55); color:#bbf7d0; }
.status--warn{ border-color: rgba(251,191,36,.55); color:#fde68a; }
.status--err{ border-color: rgba(248,113,113,.55); color:#fecaca; }
.status--loading{ border-color: rgba(129,140,248,.55); color:#e0e7ff; }

/* ==========================================================
   RESULTS
========================================================== */

.results{
  padding: 18px 0 80px;
}

.results-inner{
  width:min(1100px, calc(100% - 32px));
  margin:0 auto;
}

.results-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:14px;
  margin: 22px 0 14px;
}

.results-title{
  margin:0;
  font-size: 28px;
}

.results-meta{
  color: var(--muted);
  font-size: 13px;
  white-space:nowrap;
}

/* Table */
.table-wrap{
  border-radius: var(--radius);
  border: 1px solid rgba(148,163,184,.16);
  background: rgba(2, 6, 23, .45);
  box-shadow: var(--shadow2);
  overflow:hidden;
}

.table{
  width:100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table thead{
  background: rgba(2, 6, 23, .65);
}

.table th, .table td{
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148,163,184,.10);
  text-align:left;
}

.table th{
  font-size: 12px;
  color: rgba(156,163,175,.90);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 650;
}

.table tbody tr:hover{
  background: rgba(96,165,250,.06);
}

.table a{
  color: var(--accent);
  text-decoration:none;
  font-weight:650;
}
.table a:hover{ text-decoration:underline; }

.empty{
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px dashed rgba(148,163,184,.30);
  color: var(--muted);
  background: rgba(2, 6, 23, .40);
}

/* ==========================================================
   MODE SWITCHING
========================================================== */

body.mode-results .hero-inner{
  min-height: auto;
  padding-top: calc(var(--topbarH) + 18px);
  padding-bottom: 18px;
  gap: 10px;
}

body.mode-results .brand-title{
  font-size: clamp(28px, 3.0vw, 40px);
}

body.mode-results #searchFormHero{
  display:none;
}

body.mode-results .hint{
  display:none;
}

body.mode-results .results-head{
  margin-top: 10px;
}

/* ==========================================================
   Responsive
========================================================== */

@media (max-width: 720px){
  .topbar-inner{
    gap:10px;
  }
  .search--compact .searchbox{
    width: min(520px, 60vw);
  }
  .results-head{
    flex-direction:column;
    align-items:flex-start;
  }
  .results-meta{
    white-space:normal;
  }
  .table th, .table td{
    padding: 12px 12px;
  }
}

/* ==========================================================
   MOBILE FIX (iPhone portrait + landscape)
   This is what fixes your screenshot: huge title + card off-screen.
========================================================== */

@media (max-width: 520px){
  .hero{
    padding: 18px 0 28px;
  }
  .hero-inner{
    min-height: auto;
    padding-top: 10vh;
    gap: 14px;
  }

  .brand-title{
    font-size: clamp(30px, 10vw, 44px);
  }
  .brand-subtitle{
    font-size: 13px;
    max-width: 340px;
  }
}

/* iPhone landscape: wide but SHORT height (the worst case) */
@media (hover: none) and (pointer: coarse) and (max-height: 520px) and (orientation: landscape){
  .hero{
    padding: 10px 0 18px;
  }
  .hero-inner{
    min-height: auto;
    padding-top: 14px;
    gap: 10px;
  }

  .brand-title{
    font-size: clamp(26px, 5.8vw, 36px);
  }
  .brand-subtitle{
    font-size: 12px;
    max-width: 520px;
  }
}

/* ==========================================================
   AUTH (login / set-password / request-access)
========================================================== */

.auth-shell{
  width: 100%;
  display:flex;
  justify-content:center;
  margin-top: 12px;
}

.auth-card{
  width: min(520px, 92vw);
  max-width: 520px;

  text-align:left;
  padding: 20px 20px 18px;
  border-radius: 20px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(10,18,40,.55);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.auth-mark{
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(2,6,23,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  margin-bottom: 10px;
}

.auth-mark-dot{
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 0 5px rgba(96,165,250,.12);
}

.auth-h2{
  margin: 4px 0 2px;
  font-size: 22px;
  letter-spacing: .2px;
}

.auth-sub{
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form{
  display:flex;
  flex-direction:column;
  gap: 8px;
}

.auth-label{
  font-size: 12px;
  color: rgba(156,163,175,.95);
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 650;
  margin-top: 4px;
}

.auth-inputwrap{
  position: relative;
  display:flex;
  align-items:center;

  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.16);
  background: rgba(2, 6, 23, .45);
  box-shadow: var(--shadow2);
}

.auth-ico{
  width: 42px;
  height: 44px;
  display:flex;
  align-items:center;
  justify-content:center;
  color: rgba(229,231,235,.65);
}

.auth-ico svg{
  width: 20px;
  height: 20px;
}

.auth-input{
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 12px 12px 12px 0;
}

.auth-input::placeholder{
  color: rgba(156,163,175,.70);
}

.auth-eye{
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor:pointer;
  color: rgba(229,231,235,.65);
  display:flex;
  align-items:center;
  justify-content:center;
  border-left: 1px solid rgba(148,163,184,.10);
}
.auth-eye svg{ width: 20px; height: 20px; }
.auth-eye:hover{ color: rgba(229,231,235,.92); }

.auth-btn{
  margin-top: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(96,165,250,.35);
  background: rgba(96,165,250,.18);
  color: rgba(229,231,235,.95);
  cursor:pointer;
  font-weight: 750;
  font-size: 15px;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.auth-btn:hover{
  transform: translateY(-1px);
  background: rgba(96,165,250,.24);
  border-color: rgba(96,165,250,.50);
}
.auth-btn:active{ transform: translateY(0px); }

.auth-links{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  font-size: 13px;
}
.auth-links a{
  color: var(--accent);
  text-decoration:none;
  font-weight: 650;
}
.auth-links a:hover{ text-decoration: underline; }
.auth-dot{ color: rgba(156,163,175,.70); }

.auth-foot{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align:center;
}
.auth-foot code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: rgba(229,231,235,.92);
}

/* AUTH mobile tightening: keeps the sign-in card visible */
@media (max-width: 520px){
  .auth-shell{ margin-top: 8px; }
  .auth-card{ padding: 16px 16px 14px; border-radius: 18px; }
  .auth-h2{ font-size: 20px; }
}

@media (hover: none) and (pointer: coarse) and (max-height: 520px) and (orientation: landscape){
  .auth-shell{ margin-top: 6px; }
  .auth-card{ padding: 14px 14px 12px; }
  .auth-h2{ font-size: 18px; }
}

/* ==========================================================
   TOOLS: Import Product page UI
========================================================== */

.tool-card{
  width: min(920px, calc(100% - 32px));
  border-radius: 20px;
  border: 1px solid rgba(148,163,184,.18);
  background: rgba(10,18,40,.55);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}

.tool-label{
  font-size: 12px;
  color: rgba(156,163,175,.95);
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 650;
  margin-bottom: 8px;
}

.tool-urlwrap{
  position: relative;
  display:flex;
  align-items:center;
  gap:10px;
}

/* Make URL box visibly off-white (your request) */
.tool-urlbox{
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.32);
  background: rgba(255,255,255,.14);
}

.tool-urlinput{
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148,163,184,.20);
  background: rgba(255,255,255,.12);
  color: var(--text);
  padding: 12px 44px 12px 14px;
  outline: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.tool-urlinput::placeholder{
  color: rgba(229,231,235,.70);
}

.tool-urlinput:focus{
  border-color: rgba(96,165,250,.55);
  box-shadow: 0 0 0 4px rgba(96,165,250,.14), 0 10px 30px rgba(0,0,0,.25);
}

.tool-clear{
  position:absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,.22);
  background: rgba(2, 6, 23, .35);
  color: rgba(229,231,235,.95);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.tool-clear:hover{
  transform: translateY(-1px);
  background: rgba(2, 6, 23, .50);
  border-color: rgba(148,163,184,.35);
}
.tool-clear::before{
  content:"×";
  font-size: 20px;
  line-height: 1;
  margin-top: -1px;
}

.tool-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.tool-check{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  color: rgba(229,231,235,.88);
  font-size: 13px;
  user-select:none;
}

.tool-actions{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.tool-note{
  margin-top: 10px;
  color: rgba(156,163,175,.85);
  font-size: 12px;
}

/* ==========================================================
   PatchMon-like buttons (make them look like a real app UI)
========================================================== */

.btn{
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(148,163,184,.24);
  background: rgba(15,23,42,.70);
  color: rgba(229,231,235,.96);

  height: 38px;
  padding: 0 14px;
  border-radius: 10px;

  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 10px;

  font-weight: 750;
  font-size: 13px;
  letter-spacing: .1px;

  cursor:pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.34);
  transition: transform .12s ease, background .12s ease, border-color .12s ease, filter .12s ease;
}

.btn:hover{
  transform: translateY(-1px);
  background: rgba(30,41,59,.78);
  border-color: rgba(148,163,184,.36);
}

.btn:active{
  transform: translateY(0px);
  filter: brightness(.98);
}

.btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary = PatchMon blue vibe */
.btn--primary{
  border-color: rgba(96,165,250,.55);
  background: rgba(59,130,246,.30);
}
.btn--primary:hover{
  background: rgba(59,130,246,.40);
  border-color: rgba(96,165,250,.75);
}

/* Success = PatchMon-ish green */
.btn--success{
  border-color: rgba(34,197,94,.55);
  background: rgba(34,197,94,.22);
}
.btn--success:hover{
  background: rgba(34,197,94,.30);
  border-color: rgba(34,197,94,.75);
}

.btn--ghost{
  border-color: rgba(148,163,184,.18);
  background: rgba(2,6,23,.30);
}
.btn--ghost:hover{
  background: rgba(2,6,23,.42);
  border-color: rgba(148,163,184,.30);
}

.btn--sm{
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 10px;
}

.btn-spin{
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(229,231,235,.28);
  border-top-color: rgba(229,231,235,.92);
  animation: btnspin 0.75s linear infinite;
}
@keyframes btnspin { to { transform: rotate(360deg); } }

/* ==========================================================
   Debug JSON block
========================================================== */

.tool-raw{
  margin-top: 14px;
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,.16);
  background: rgba(2, 6, 23, .45);
  overflow:hidden;
}

/* When we want the JSON to grow with page (no vertical scroll) */
.tool-raw--grow{
  overflow: visible !important;
}

.tool-rawhead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148,163,184,.10);
}

.tool-pre{
  margin:0;
  padding: 12px;
  font-size: 12px;
  overflow:auto;
  max-height: 360px;
  color: rgba(229,231,235,.92);
}

/* No vertical scrollbars; let the page scroll */
.tool-pre--novscroll{
  max-height: none !important;
  overflow-y: visible !important;
  overflow-x: auto !important;
  white-space: pre;
}

.tool-subnote{
  margin-top: 6px;
  color: rgba(156,163,175,.85);
  font-size: 12px;
}
.tool-subnote code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: rgba(229,231,235,.92);
}
