/* ==========================================================================
   Support My Work: styles
   Palette and type follow the Hugo "Stack" theme used on u77w41.github.io
   ========================================================================== */

/* ---------- Theme tokens ---------- */
:root {
  /* Light (default) */
  --body-background: #f5f5fa;
  --card-background: #ffffff;
  --card-background-muted: #f7f7fb;
  --text-main: #111418;
  --text-body: #4f5660;
  --text-muted: #6b7079;
  --border: #e3e4ec;
  --border-strong: #cfd1dc;
  --accent: #34495e;
  --accent-darker: #2c3e50;
  --accent-text: #ffffff;
  --focus-ring: #3b82f6;
  --danger: #b4232c;
  --danger-bg: rgba(180, 35, 44, 0.07);
  --success: #1f7a3a;

  --shadow-l1: 0 4px 8px rgba(0, 0, 0, 0.04), 0 0 2px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-l2: 0 10px 20px rgba(0, 0, 0, 0.04), 0 2px 6px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.04);

  --font-sans: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --radius-card: 10px;
  --radius-control: 8px;
  --radius-tag: 4px;
  --container: 960px;
  --gutter: 16px;

  color-scheme: light;
}

:root[data-scheme="dark"] {
  --body-background: #303030;
  --card-background: #424242;
  --card-background-muted: #3a3a3a;
  --text-main: rgba(255, 255, 255, 0.92);
  --text-body: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(255, 255, 255, 0.6);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --accent: #ecf0f1;
  --accent-darker: #bdc3c7;
  --accent-text: #111418;
  --focus-ring: #8ab4ff;
  --danger: #ff9a9f;
  --danger-bg: rgba(255, 120, 128, 0.1);
  --success: #8fe0a6;

  --shadow-l1: 0 4px 8px rgba(0, 0, 0, 0.18), 0 0 2px rgba(0, 0, 0, 0.2);
  --shadow-l2: 0 10px 20px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.2);

  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--body-background);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Smooth theme switch, enabled by script.js after first paint so the initial load doesn't animate */
.theme-ready body,
.theme-ready .site-header,
.theme-ready .pay-card,
.theme-ready .amount-field,
.theme-ready .copy-button,
.theme-ready .ghost-button,
.theme-ready .theme-toggle,
.theme-ready .pay-button,
.theme-ready .upi-row,
.theme-ready .trust-note {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

button {
  font: inherit;
  color: inherit;
}

code,
.mono {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.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: -48px;
  z-index: 10;
  padding: 8px 14px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

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

/* ---------- Header ---------- */
.site-header {
  background: var(--card-background);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "brand nav toggle";
  align-items: center;
  gap: 12px 24px;
  min-height: 72px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: var(--shadow-l1);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.brand-name {
  color: var(--accent);
  font-weight: 700;
  font-size: 17px;
}

.brand-tagline {
  color: var(--text-muted);
  font-size: 13px;
  text-wrap: balance;
}

.brand:hover .brand-name {
  opacity: 0.8;
}

.site-nav {
  grid-area: nav;
}

.site-nav ul {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-control);
  color: var(--text-body);
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text-main);
  background: var(--card-background-muted);
}

.site-nav .icon {
  width: 18px;
  height: 18px;
}

.theme-toggle {
  grid-area: toggle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card-background);
  color: var(--text-main);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  background: var(--card-background-muted);
}

/* Moon in light mode (click for dark), sun in dark mode (click for light) */
.theme-toggle .icon-sun,
:root[data-scheme="dark"] .theme-toggle .icon-moon {
  display: none;
}

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

/* ---------- Intro ---------- */
main.container {
  flex: 1;
  padding-top: 40px;
  padding-bottom: 40px;
}

.intro {
  max-width: 680px;
  margin-bottom: 28px;
}

.intro h1 {
  color: var(--text-main);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.intro p {
  font-size: 17px;
  line-height: 1.7;
}

/* ---------- Payment card ---------- */
.pay-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0;
  background: var(--card-background);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-l1);
  overflow: hidden;
}

.pay-controls {
  padding: 32px;
}

.pay-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 28px;
  background: var(--card-background-muted);
  border-left: 1px solid var(--border);
}

/* On desktop the QR is the primary path, so it sits first */
@media (min-width: 821px) {
  .pay-qr {
    order: -1;
    border-left: 0;
    border-right: 1px solid var(--border);
  }

  .pay-card {
    grid-template-columns: 320px minmax(0, 1fr);
  }
}

/* ---------- Amount input ---------- */
.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
}

.amount-field {
  display: flex;
  align-items: center;
  height: 60px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--card-background);
}

.amount-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 30%, transparent);
}

.amount-field.is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.amount-field.is-invalid:focus-within {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent);
}

.amount-prefix,
.amount-suffix {
  font-family: var(--font-mono);
  color: var(--text-muted);
  user-select: none;
}

.amount-prefix {
  font-size: 24px;
  margin-right: 8px;
}

.amount-suffix {
  font-size: 13px;
  letter-spacing: 0.06em;
}

.amount-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
}

.amount-help {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  margin: 6px 0 10px;
  color: var(--danger);
  font-size: 13.5px;
}

.amount-help:empty {
  visibility: hidden;
}

/* ---------- Preset pills (same pastel pairs as the blog's category tags) ---------- */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.preset {
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-tag);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.preset:hover {
  filter: brightness(0.96);
}

.preset:active {
  transform: translateY(1px);
}

.preset[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--card-background), 0 0 0 4px var(--accent);
}

.preset--purple { background: #ddbeef; color: #2c0f3d; }
.preset--green  { background: #beefc1; color: #0f3d12; }
.preset--blue   { background: #becfef; color: #0f1f3d; }
.preset--pink   { background: #efbec8; color: #3d0f19; }

/* ---------- Pay button ---------- */
.pay-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 12px 20px;
  border-radius: var(--radius-card);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-l1);
}

.pay-button:hover {
  background: var(--accent-darker);
  box-shadow: var(--shadow-l2);
}

.pay-button:active {
  transform: translateY(1px);
}

.pay-button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.pay-button span {
  font-variant-numeric: tabular-nums;
}

.pay-hint {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- Divider + UPI ID ---------- */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.upi-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--card-background-muted);
}

.upi-id {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 15px;
  user-select: all;
}

.copy-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--card-background);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.copy-button:hover,
.ghost-button:hover {
  border-color: var(--accent);
}

.copy-button .icon,
.ghost-button .icon {
  width: 17px;
  height: 17px;
}

.copy-button .icon-check {
  display: none;
}

.copy-button.is-copied {
  border-color: var(--success);
  color: var(--success);
}

.copy-button.is-copied .icon-copy {
  display: none;
}

.copy-button.is-copied .icon-check {
  display: block;
}

.payee-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin: 14px 0 0;
  font-size: 13.5px;
}

.payee-meta div {
  display: flex;
  gap: 6px;
}

.payee-meta dt {
  color: var(--text-muted);
}

.payee-meta dt::after {
  content: ":";
}

.payee-meta dd {
  margin: 0;
  color: var(--text-main);
}

/* ---------- QR panel ---------- */
.qr-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 700;
}

.qr-title .icon {
  width: 18px;
  height: 18px;
}

.qr-title-extra {
  display: none;
  font-weight: 400;
  color: var(--text-muted);
}

/* Always white with dark modules, in both themes, so cameras read it reliably */
.qr-box {
  position: relative;
  display: grid;
  place-items: center;
  width: 256px;
  height: 256px;
  padding: 0;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e3e4ec;
  box-shadow: var(--shadow-l1);
}

.qr-code {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

/* script.js sets the exact pixel size; this is just the pre-JS default */
.qr-code svg {
  width: 82%;
  height: 82%;
  shape-rendering: crispEdges;
}

.qr-box.is-disabled .qr-code {
  visibility: hidden;
}

.qr-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  color: #5b616b;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
}

.qr-placeholder[hidden] {
  display: none;
}

.qr-placeholder .icon {
  width: 28px;
  height: 28px;
  color: #8a909a;
}

.qr-caption {
  color: var(--text-body);
  font-size: 14px;
  text-align: center;
}

.qr-caption .mono {
  color: var(--text-main);
  font-weight: 700;
}

.ghost-button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.noscript-note {
  grid-column: 1 / -1;
  padding: 16px 32px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

/* ---------- Trust note + toast ---------- */
.trust-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.trust-note .icon {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-l2);
  transform: translateX(-50%);
  animation: toast-in 0.25s ease;
}

.toast[hidden] {
  display: none;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Footer (mirrors the Stack theme footer) ---------- */
.site-footer {
  padding: 8px 0 40px;
  font-size: 14px;
  line-height: 1.75;
}

.site-footer .container::before {
  content: "";
  display: block;
  width: 50px;
  height: 3px;
  margin-bottom: 18px;
  background: var(--text-body);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-bottom: 6px;
}

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

.footer-nav a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.copyright {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .pay-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .pay-qr {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .qr-title-extra {
    display: inline;
  }
}

/* Phones: nav drops to its own row under the name */
@media (max-width: 640px) {
  .header-inner {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand toggle"
      "nav nav";
    min-height: 0;
    padding-bottom: 0;
  }

  .site-nav {
    padding-bottom: 8px;
  }

  .site-nav ul {
    gap: 4px;
    margin-left: -8px; /* line the first icon up with the avatar while keeping hover padding */
  }

  .site-nav a {
    padding: 6px 8px;
    font-size: 14px;
  }
}

@media (max-width: 560px) {
  :root {
    --gutter: 16px;
  }

  main.container {
    padding-top: 24px;
    padding-bottom: 28px;
  }

  .brand-avatar {
    width: 38px;
    height: 38px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-tagline {
    font-size: 12px;
  }

  .intro {
    margin-bottom: 20px;
  }

  .intro h1 {
    font-size: 26px;
  }

  .intro p {
    font-size: 16px;
  }

  .pay-controls {
    padding: 20px;
  }

  .pay-qr {
    padding: 24px 20px;
  }

  .qr-box {
    width: 240px;
    height: 240px;
  }

  .presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .preset {
    padding: 10px 4px;
  }

  .pay-button {
    min-height: 56px;
  }

  .upi-row {
    flex-wrap: wrap;
  }

  .upi-id {
    flex-basis: 100%;
    padding: 4px 0;
  }

  .copy-button {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .theme-toggle,
  .pay-button,
  .ghost-button,
  .copy-button,
  .toast {
    display: none !important;
  }

  .pay-card {
    box-shadow: none;
  }
}
