/* moveto.my — design system
   Inspired by allaboutberlin.com's approach: plain HTML/CSS, no framework,
   task-oriented card navigation, generous whitespace, native dark mode. */

:root {
  color-scheme: light dark;

  /* spacing scale */
  --s-xs: 0.4rem;
  --s-sm: 0.75rem;
  --s-md: 1.25rem;
  --s-lg: 2rem;
  --s-xl: 3.5rem;
  --s-xxl: 5.5rem;

  /* type scale */
  --f-sm: 0.9rem;
  --f-base: 1.0625rem;
  --f-lg: 1.25rem;
  --f-xl: 1.75rem;
  --f-xxl: 2.5rem;
  --line-text: 1.65;
  --line-heading: 1.25;

  /* layout */
  --w-content: 720px;
  --w-wide: 1120px;
  --radius: 10px;

  /* brand accents, drawn from the Jalur Gemilang (Malaysia flag) palette,
     toned down for a light, content-first UI rather than flag colours
     used decoratively */
  --accent: #1c3f7c;
  --accent-dark: #142c58;
  --gold: #d99a2b;
  --red: #b3301f;

  /* light mode (default) */
  --bg: #ffffff;
  --bg-raised: #f6f5f2;
  --bg-card: #faf9f6;
  --text: #1a1a1a;
  --text-muted: #5a5a5a;
  --border: #e6e3dc;
  --link: var(--accent);
  --link-visited: var(--accent-dark);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --bg-raised: #1b1e23;
    --bg-card: #1e2126;
    --text: #ececec;
    --text-muted: #a3a3a3;
    --border: #2c2f35;
    --link: #7fa4e0;
    --link-visited: #a98be0;
    --accent: #4b74b8;
    --gold: #e6b04e;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --bg-raised: #1b1e23;
  --bg-card: #1e2126;
  --text: #ececec;
  --text-muted: #a3a3a3;
  --border: #2c2f35;
  --link: #7fa4e0;
  --link-visited: #a98be0;
  --accent: #4b74b8;
  --gold: #e6b04e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--f-base);
  line-height: var(--line-text);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:visited {
  color: var(--link-visited);
}

a:hover {
  text-decoration-thickness: 2px;
}

h1,
h2,
h3,
h4 {
  line-height: var(--line-heading);
  font-weight: 700;
  margin: var(--s-lg) 0 var(--s-sm);
  scroll-margin-top: var(--s-xl);
}

h1 {
  font-size: var(--f-xxl);
  margin-top: 0;
}

h2 {
  font-size: var(--f-xl);
}

h3 {
  font-size: var(--f-lg);
}

p,
ul,
ol {
  margin: 0 0 var(--s-md);
}

ul,
ol {
  padding-left: 1.3em;
}

/* ---------- layout shells ---------- */

.wrap {
  max-width: var(--w-wide);
  margin: 0 auto;
  padding: 0 var(--s-lg);
}

.content {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: 0 var(--s-lg);
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--s-md);
  padding-bottom: var(--s-md);
  gap: var(--s-lg);
}

.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  height: 26px;
  width: auto;
  display: block;
}

nav.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-lg);
}

nav.site-nav ul {
  display: flex;
  gap: var(--s-md);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--f-sm);
  font-weight: 600;
}

nav.site-nav a {
  color: var(--text);
  text-decoration: none;
}

nav.site-nav a:hover {
  color: var(--accent);
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: var(--accent);
  color: #fff !important;
  padding: 0.55em 1.1em;
  border-radius: 999px;
  font-size: var(--f-sm);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.btn-discord:hover {
  background: var(--accent-dark);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-md);
  max-width: 480px;
  margin: var(--s-lg) 0;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
}

.form-row label {
  font-size: var(--f-sm);
  font-weight: 600;
  color: var(--text-muted);
}

.form-row input,
.form-row textarea {
  font: inherit;
  padding: 0.6em 0.8em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text);
}

.form-row input:focus,
.form-row textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.contact-form button[type="submit"] {
  align-self: flex-start;
  border: none;
  cursor: pointer;
  font: inherit;
}

.contact-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

.form-status {
  font-size: var(--f-sm);
  color: var(--text-muted);
  min-height: 1.2em;
  margin: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4em;
  height: 2.4em;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle .icon-dark {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-light {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-dark {
  display: inline;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-light {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-dark {
    display: inline;
  }
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4em 0.6em;
  font-size: 1.1rem;
  color: var(--text);
}

/* ---------- search ---------- */

.search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4em;
  height: 2.4em;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.search-toggle:hover {
  border-color: var(--accent);
}

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh var(--s-lg) var(--s-lg);
}

.search-overlay[hidden] {
  display: none;
}

.search-panel {
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.search-panel-header {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  padding: var(--s-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.search-panel-header input {
  flex: 1;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--f-lg);
  color: var(--text);
}

.search-panel-header input:focus {
  outline: none;
}

.search-panel-header input::placeholder {
  color: var(--text-muted);
}

#search-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2em;
}

.search-results {
  overflow-y: auto;
  padding: var(--s-sm);
}

.search-result {
  display: block;
  padding: var(--s-sm) var(--s-md);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}

.search-result:hover,
.search-result:focus {
  background: var(--bg-raised);
}

.search-result h3 {
  margin: 0 0 0.2em;
  font-size: var(--f-base);
}

.search-result p {
  margin: 0;
  font-size: var(--f-sm);
  color: var(--text-muted);
}

.search-result mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
}

.search-empty,
.search-hint {
  padding: var(--s-md);
  font-size: var(--f-sm);
  color: var(--text-muted);
}

/* ---------- hero ---------- */

.hero {
  padding: var(--s-xxl) 0 var(--s-xl);
  text-align: center;
}

.hero h1 {
  margin-bottom: var(--s-sm);
}

.hero p.lede {
  font-size: var(--f-lg);
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- topic card grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-md);
  padding: var(--s-xl) 0 var(--s-xxl);
}

.card-grid-inline {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  padding: var(--s-md) 0 var(--s-lg);
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-xl) var(--s-lg);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:visited {
  color: var(--text);
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: var(--s-xs);
}

:root[data-theme="dark"] .card img {
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card img {
    filter: invert(1);
  }
}

.card h3 {
  margin: 0;
  font-size: var(--f-base);
}

.card p {
  margin: 0;
  font-size: var(--f-sm);
  color: var(--text-muted);
}

/* ---------- article / guide pages ---------- */

.guide-layout {
  max-width: var(--w-wide);
  margin: 0 auto;
  padding: var(--s-xl) var(--s-lg) var(--s-xxl);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--s-xl);
  align-items: start;
}

.guide-main {
  max-width: var(--w-content);
}

.guide-layout.no-sidebar {
  grid-template-columns: 1fr;
}

.guide-layout.no-sidebar .guide-main {
  margin: 0 auto;
}

.toc-sidebar {
  position: sticky;
  top: var(--s-lg);
  display: flex;
  flex-direction: column;
  gap: var(--s-lg);
}

.toc-sidebar h2 {
  font-size: var(--f-sm);
  margin: 0 0 var(--s-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-sm);
}

.toc-header h2 {
  margin: 0;
}

.toc-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2em;
  flex-shrink: 0;
}

.toc-toggle svg {
  transition: transform 0.15s ease;
}

.toc-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-lg);
}

.toc-sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--f-sm);
  border-left: 2px solid var(--border);
}

.toc-sidebar li {
  margin: 0;
}

.toc-sidebar ul a {
  display: block;
  padding: 0.3em 0 0.3em var(--s-sm);
  color: var(--text-muted);
  text-decoration: none;
}

.toc-sidebar ul a:visited {
  color: var(--text-muted);
}

.toc-sidebar ul a:hover {
  color: var(--accent);
}

.toc-donate {
  font-size: var(--f-sm);
  color: var(--text-muted);
  margin: 0;
}

.toc-donate a,
.toc-donate a:visited {
  color: var(--gold);
  font-weight: 600;
}

.article-header {
  padding-bottom: var(--s-md);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-xl);
}

.breadcrumb {
  font-size: var(--f-sm);
  color: var(--text-muted);
  margin-bottom: var(--s-sm);
}

.breadcrumb a {
  color: var(--text-muted);
}

article {
  padding-bottom: var(--s-xxl);
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  padding: var(--s-xl) 0;
  margin-top: var(--s-xl);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-lg);
  font-size: var(--f-sm);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-note {
  color: var(--text-muted);
  max-width: 420px;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  nav.site-nav {
    position: relative;
  }

  nav.site-nav ul {
    display: none;
  }

  nav.site-nav.open ul {
    display: flex;
    flex-direction: column;
    gap: var(--s-sm);
    position: absolute;
    top: calc(100% + var(--s-md));
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s-md);
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    z-index: 10;
  }

  .nav-toggle {
    display: inline-block;
  }

  .hero {
    padding: var(--s-xl) 0 var(--s-lg);
  }

  .hero h1 {
    font-size: var(--f-xl);
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .card {
    padding: var(--s-lg) var(--s-md);
  }

  .card img {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 900px) {
  .guide-layout {
    grid-template-columns: 1fr;
  }

  .guide-main {
    max-width: none;
  }

  .toc-sidebar {
    position: static;
    max-height: none;
    padding-bottom: var(--s-md);
    margin-bottom: var(--s-lg);
    border-bottom: 1px solid var(--border);
  }

  .toc-header {
    cursor: pointer;
  }

  .toc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .toc-body {
    display: none;
  }

  .toc-sidebar.open .toc-body {
    display: flex;
    margin-top: var(--s-md);
  }

  .toc-sidebar.open .toc-toggle svg {
    transform: rotate(180deg);
  }
}
