/* ==========================================================================
   Rent Delusion stylesheet
   Clean, light, lots of whitespace. System fonts. One restrained accent.
   No gradients, glow, or neon.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f8f9fa;
  --border: #e3e6ea;
  --text: #202124;
  --text-muted: #5f6368;
  --accent: #1a73e8;
  --accent-dark: #1759b3;
  --danger: #c5221f;
  --danger-bg: #fce8e6;
  --high: #c5221f;
  --mid: #e8710a;
  --low: #1e8e3e;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.1), 0 1px 3px rgba(60, 64, 67, 0.08);
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

/* Never let media or long words (e.g. source URLs) force horizontal scroll. */
img, svg, video { max-width: 100%; height: auto; }
body { overflow-wrap: break-word; }
a { overflow-wrap: anywhere; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.25; font-weight: 600; color: var(--text); }
h1 { font-size: 2rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1rem 0 0.5rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

p { margin: 0 0 1rem; }
.muted { color: var(--text-muted); }
.tiny { font-size: 0.8rem; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: 8px 12px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Header ------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  background: var(--accent); color: #fff; border-radius: 7px; font-weight: 700;
}
.site-nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.site-nav a { color: var(--text-muted); font-size: 0.95rem; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav-cta {
  background: var(--accent); color: #fff !important; padding: 7px 14px; border-radius: var(--radius-sm);
}
.nav-cta:hover { background: var(--accent-dark); text-decoration: none; }
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; color: var(--text-muted); font: inherit; cursor: pointer; padding: 0;
}
.link-button:hover { color: var(--text); }

/* Hamburger toggle: hidden on desktop, shown on mobile. */
.nav-toggle {
  display: none; background: none; border: 0; padding: 8px; cursor: pointer; margin-left: auto;
}
.nav-toggle-bar { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
.nav-toggle-bar + .nav-toggle-bar { margin-top: 5px; }

/* --- Main / layout ------------------------------------------------------ */
main { flex: 1 0 auto; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 2rem 16px 3rem; }

.section { margin: 2.5rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-link { font-size: 0.95rem; white-space: nowrap; }
.page-head { margin: 0.5rem 0 1.5rem; }

/* --- Buttons ------------------------------------------------------------ */
.button {
  display: inline-block; cursor: pointer; font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  text-align: center; transition: background 0.15s, border-color 0.15s;
}
.button:hover { text-decoration: none; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-dark); }
.button-ghost { background: var(--surface); color: var(--accent); border-color: var(--border); }
.button-ghost:hover { background: var(--surface-alt); }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { background: #a01714; }
.button-sm { padding: 6px 12px; font-size: 0.85rem; }

/* --- Hero --------------------------------------------------------------- */
.hero { padding: 2.5rem 0 1.5rem; max-width: 760px; }
.hero-title { font-size: 2.6rem; letter-spacing: -0.02em; margin-bottom: 1rem; }
.hero-title .accent { color: var(--accent); }
.hero-lede { font-size: 1.2rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* --- Stats -------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; text-align: center; display: flex; flex-direction: column; gap: 0.25rem;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { color: var(--text-muted); font-size: 0.9rem; }
.stat-source { font-size: 0.75rem; }

/* --- Cards & grid ------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

.listing-card { padding: 0; overflow: hidden; margin: 0; }
.listing-card-link { display: block; padding: 1.1rem; color: var(--text); height: 100%; }
.listing-card-link:hover { text-decoration: none; background: var(--surface-alt); }
.listing-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.listing-card-country { color: var(--text-muted); font-size: 0.85rem; }
.listing-card-title { font-size: 1.05rem; margin: 0 0 0.5rem; }
.listing-card-meta { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* --- Score badges ------------------------------------------------------- */
.score-badge {
  display: inline-grid; place-items: center; min-width: 2.2rem; height: 2.2rem; padding: 0 0.4rem;
  border-radius: 999px; font-weight: 700; color: #fff; background: var(--text-muted); font-size: 0.95rem;
}
.score-low { background: var(--low); }
.score-mid { background: var(--mid); }
.score-high { background: var(--high); }
.score-xl { min-width: 4rem; height: 4rem; font-size: 1.6rem; }
.score-hero { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }

/* --- Rankings ----------------------------------------------------------- */
.ranking-list { list-style: none; margin: 0; padding: 0; }
.ranking-row {
  display: flex; align-items: center; gap: 1rem; padding: 0.85rem 0.25rem;
  border-bottom: 1px solid var(--border);
}
.ranking-pos { width: 1.75rem; font-weight: 700; color: var(--text-muted); text-align: center; }
.ranking-country { flex: 1; font-weight: 600; color: var(--text); }
.ranking-count { font-size: 0.85rem; }
.ranking-score { margin-left: auto; font-weight: 700; }

/* --- CTA band ----------------------------------------------------------- */
.cta-band {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; text-align: center;
}
.cta-band h2 { margin-bottom: 0.5rem; }
.cta-band p { color: var(--text-muted); max-width: 540px; margin: 0 auto 1.25rem; }
.cta-inline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 2rem 0; }

/* --- Filters / pagination ---------------------------------------------- */
.filter-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filter-bar select { max-width: 280px; }
.pagination { display: flex; gap: 0.75rem; justify-content: center; margin-top: 2rem; }

/* --- Listing detail ----------------------------------------------------- */
.listing-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.breadcrumb { font-size: 0.85rem; margin-bottom: 0.25rem; }
.listing-sub { margin: 0; }
.listing-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.listing-gallery img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); display: block; }
.listing-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1.5rem; margin: 0.5rem 0 1rem; }
.facts > div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dotted var(--border); padding: 0.3rem 0; }
.facts dt { color: var(--text-muted); margin: 0; }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

.redflag-list { margin: 0.25rem 0 1rem; padding-left: 1.2rem; }
.redflag-list li { color: var(--high); }
.source-link { font-weight: 600; }
.tag {
  display: inline-block; background: var(--danger-bg); color: var(--high); border-radius: 999px;
  padding: 2px 10px; font-size: 0.8rem; margin: 0 4px 4px 0;
}

/* --- Sub-scores / meters ------------------------------------------------ */
.subscore { margin-bottom: 1rem; }
.subscore-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.3rem; font-size: 0.95rem; }
.subscore-label { font-weight: 600; }
.meter { height: 8px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.meter-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.subscore-reasons { margin: 0.4rem 0 0; padding-left: 1.2rem; color: var(--text-muted); font-size: 0.88rem; }

/* --- Forms -------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 0.35rem; }
.form label { font-weight: 600; font-size: 0.95rem; margin-top: 0.5rem; }
.form .muted { font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
.form button { margin-top: 1rem; align-self: flex-start; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.submit-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin: 0 0 1.25rem; }
.submit-form legend { font-weight: 600; padding: 0 0.5rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0.75rem 0; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin: 0; }
.check input { width: auto; }

.auth-card { max-width: 440px; margin: 2rem auto; }
.auth-card.center { text-align: center; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 0.75rem 1rem; border-radius: var(--radius-sm); }
.form-success { background: #e6f4ea; color: var(--low); padding: 0.75rem 1rem; border-radius: var(--radius-sm); }
.notice { border-left: 4px solid var(--accent); }
.notice-inline { background: var(--surface-alt); padding: 0.75rem 1rem; border-radius: var(--radius-sm); }

.cf-turnstile { margin: 0.75rem 0; }

/* --- Tables ------------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--text-muted); font-weight: 600; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.edit-details { margin-top: 0.4rem; }
.edit-details summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
.edit-details .form { margin-top: 0.5rem; max-width: 360px; }

.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; text-transform: capitalize; }
.status-pending { background: #fef7e0; color: #b06000; }
.status-approved { background: #e6f4ea; color: var(--low); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }

/* --- Admin -------------------------------------------------------------- */
.admin-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 0.25rem; }
.admin-actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.admin-review-form { margin-top: 1rem; }
.weight-field { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; gap: 0.75rem; margin: 0.4rem 0; }
.weight-field label { margin: 0; }
.danger-zone { border-top: 1px solid var(--border); padding-top: 1.5rem; }

/* --- Formula page ------------------------------------------------------- */
.prose { max-width: 760px; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 0.3rem; }
.formula-weights { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.weight-row { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.9rem; background: var(--surface-alt); border-radius: var(--radius-sm); }
.weight-pill { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 12px; font-weight: 700; font-size: 0.85rem; }
.reference-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 0.75rem; }
.reference-table th, .reference-table td { border: 1px solid var(--border); padding: 0.35rem 0.5rem; text-align: right; }
.reference-table th:first-child, .reference-table td:first-child { text-align: left; }
.reference-table thead th { background: var(--surface-alt); }

/* --- Calculator --------------------------------------------------------- */
.calc-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.calc-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin: 0 0 1.25rem; }
.calc-form legend { font-weight: 600; padding: 0 0.5rem; }
.calc-result { position: sticky; top: 76px; }
.calc-result .score-hero { margin-bottom: 1rem; }

.pull-quote { border-left: 4px solid var(--accent); margin: 1rem 0; padding: 0.5rem 0 0.5rem 1.25rem; }
.pull-quote p { font-size: 1.25rem; font-style: italic; margin-bottom: 0.5rem; }
.pull-quote cite { color: var(--text-muted); font-style: normal; font-size: 0.9rem; }
.qr { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.contact-block { font-size: 1.1rem; font-weight: 600; }
code { background: var(--surface-alt); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

/* --- Footer ------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface-alt); margin-top: 3rem; }
.footer-inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.4fr; gap: 1.5rem; padding: 2.5rem 16px 1.5rem; }
.footer-brand { font-weight: 700; margin-bottom: 0.25rem; }
.footer-head { font-weight: 600; font-size: 0.85rem; color: var(--text); margin: 0 0 0.5rem; }
.footer-nav { display: flex; flex-direction: column; gap: 0.35rem; }
.footer-nav a, .footer-social a { color: var(--text-muted); font-size: 0.9rem; }
.footer-social { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.newsletter-form { display: flex; flex-direction: column; gap: 0.5rem; }
.newsletter-form input { font-size: 0.9rem; }
.footer-bottom { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 16px 1.5rem; border-top: 1px solid var(--border); font-size: 0.82rem; }

/* --- Error page --------------------------------------------------------- */
.error-page { text-align: center; padding: 3rem 0; }
.error-code { font-size: 4rem; font-weight: 700; color: var(--accent); margin: 0; line-height: 1; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 720px) {
  h1 { font-size: 1.6rem; }
  .hero-title { font-size: 2rem; }
  .listing-columns { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .weight-field { grid-template-columns: 1fr 80px; }
  .weight-field .muted { grid-column: 2; text-align: right; }
  .site-header { position: static; }
  /* Wide tables become horizontally scrollable instead of overflowing the page. */
  .data-table, .reference-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .facts { grid-template-columns: 1fr; }

  /* Mobile navigation: show the hamburger, collapse the nav into a dropdown. */
  .header-inner { flex-wrap: wrap; height: auto; min-height: 60px; }
  .nav-toggle { display: block; }
  .site-nav {
    display: none; width: 100%; flex-direction: column; align-items: stretch;
    gap: 0; padding: 0.25rem 0 0.75rem;
  }
  .site-header.nav-open .site-nav { display: flex; }
  .site-nav a, .site-nav .inline-form { padding: 0.75rem 0.25rem; border-top: 1px solid var(--border); }
  .site-nav .inline-form { display: block; }
  .nav-cta { background: none; color: var(--accent) !important; padding: 0.75rem 0.25rem; }
  .nav-cta:hover { background: var(--surface-alt); }

  /* Calculator: single column, with the live result shown above the form. */
  .calc-layout { grid-template-columns: 1fr; }
  .calc-result { position: static; order: -1; }
}
@media (max-width: 460px) {
  .footer-inner { grid-template-columns: 1fr; }
  .site-nav { gap: 0.85rem; }
}
