/* extra styles – editable without redeploying the worker */

/* Share the same branded layout on sign-in, two-factor verification and registration screens. */
body:has(.auth form:is([action="/login"], [action="/register"], [action="/2fa"])) {
  background: #e7edf1;
}
[data-theme="dark"] body:has(.auth form:is([action="/login"], [action="/register"], [action="/2fa"])) {
  background: #0a1523;
}
.auth:has(form:is([action="/login"], [action="/register"], [action="/2fa"])) {
  --gutter: clamp(28px, 4.4vw, 76px);
  --frame: clamp(18px, 2.2vw, 34px);
  --mast: 78px;
  --surface: #fff;
  --field: #f8fafb;
  --text: #152c42;
  --secondary: #50667a;
  --stroke: #b9c8d2;
  --accent: #245fc1;
  --accent-hover: #164caa;
  --focus: #266bc8;
  --photo-angle: 96deg;

  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(365px, 38%);
  grid-template-rows: var(--mast) minmax(min-content, 1fr);
  width: min(1540px, calc(100% - 2 * var(--frame)));
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding-block-end: var(--frame);
  color: var(--text);
  line-height: 1.5;

  &::before {
    content: "";
    position: absolute;
    inset: var(--mast) 0 var(--frame);
    z-index: -1;
    border-radius: 16px;
    background: linear-gradient(var(--photo-angle), rgb(6 25 47 / 76%), rgb(10 33 59 / 25%) 56%, transparent 85%),
      linear-gradient(0deg, rgb(6 21 40 / 55%), transparent 42%),
      #254567 url("/assets/pattaya-bay.png") center 58% / cover no-repeat;
  }
  & .brand { display: contents; }
  & .brand::after { content: none; }
  & .brand .logo {
    grid-area: 1 / 1;
    align-self: center;
    justify-self: start;
    margin-inline-start: 4px;
  }
  & .brand .logo img {
    width: clamp(175px, 18vw, 235px);
    max-width: 100%;
    content: url("/assets/logo-dark.png");
  }
  & .tgs {
    position: static;
    grid-area: 1 / 2;
    align-self: center;
    justify-self: end;
    display: flex;
    gap: 8px;
  }
  & .tg {
    height: 38px;
    padding-inline: 16px;
    border: 1px solid var(--stroke);
    border-radius: 99px;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
  }
  & .tg:hover { background: var(--surface); }
  & .hero {
    display: block;
    grid-area: 2 / 1;
    align-self: center;
    margin: 0 var(--gutter);
    padding-block: 84px 110px;
    color: #fff;
    text-shadow: 0 1px 12px rgb(6 22 39 / 20%);
  }
  & .hero::before {
    content: "";
    display: block;
    width: 50px;
    height: 3px;
    margin-block-end: 24px;
    background: #efc57c;
  }
  & .hero h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(48px, 5vw, 82px);
    font-weight: 300;
    letter-spacing: -.045em;
    line-height: 1.06;
    text-wrap: balance;
  }
  & .hero p {
    max-width: 33ch;
    margin-block-start: 22px;
    color: #eef4f9;
    font-size: clamp(16px, 1.35vw, 21px);
    line-height: 1.65;
    text-wrap: pretty;
  }
  & .brand small {
    grid-area: 2 / 1;
    align-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 var(--gutter) 36px;
    color: #fff5dd;
    font-weight: 600;
    font-size: 13px;
  }
  & .brand small::before {
    content: "";
    width: 8px;
    height: 8px;
    background: #e9bb77;
    border: 3px solid #344552;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #e9bb77;
  }
  & .panel {
    grid-area: 2 / 2;
    align-self: center;
    margin-block: clamp(32px, 5vh, 60px);
    margin-inline-end: var(--gutter);
    padding: 0;
  }
  & .box {
    max-width: 492px;
    padding: clamp(26px, 2.65vw, 44px);
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid rgb(121 153 181 / 28%);
    box-shadow: 0 20px 56px rgb(6 22 39 / 28%);
  }
  & .box h2 { margin: 0; font-size: 36px; font-weight: 600; line-height: 1.2; letter-spacing: -.035em; }
  & .sub { margin: 5px 0 24px; color: var(--secondary); font-size: 16px; }
  & label { margin-block: 15px 6px; font-size: 14px; font-weight: 600; }
  & input:is([type="text"], [type="password"]) {
    height: 48px;
    border: 1px solid var(--stroke);
    border-radius: 7px;
    background: var(--field);
    color: var(--text);
  }
  & :is(input, button, a):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  & .row { margin: 18px 0; }
  & .chk { margin: 0; color: var(--secondary); font-size: 14px; font-weight: 400; cursor: pointer; }
  & .chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
  & .btn {
    height: 48px;
    margin: 0;
    border-radius: 7px;
    background: var(--accent);
    color: white;
    font-weight: 600;
  }
  & .btn:hover { background: var(--accent-hover); }
  & .or { margin: 14px 0; color: var(--secondary); }
  & .or::before, & .or::after { background: var(--stroke); opacity: .65; }
  & .btn.ghost { border: 1px solid var(--stroke); background: var(--field); color: var(--text); }
  & .btn.ghost:hover { background: var(--surface); border-color: var(--focus); }
  & .note {
    margin: 20px 0 0;
    padding-block-start: 15px;
    border-block-start: 1px solid var(--stroke);
    color: var(--secondary);
    font-size: 13px;
    line-height: 1.6;
  }
}

[dir="rtl"] .auth:has(form:is([action="/login"], [action="/register"], [action="/2fa"])) {
  --photo-angle: 264deg;
  & .hero h1 { letter-spacing: -.025em; line-height: 1.12; }
}
[data-theme="dark"] .auth:has(form:is([action="/login"], [action="/register"], [action="/2fa"])) {
  --surface: #14273b;
  --field: #102133;
  --text: #f1f5f9;
  --secondary: #beccda;
  --stroke: #475f75;
  --accent: #2c64ca;
  --accent-hover: #2457b5;
  --focus: #9dc8ff;
  & .brand .logo img { content: normal; }
}

@media (max-width: 800px) {
  .auth:has(form:is([action="/login"], [action="/register"], [action="/2fa"])) {
    --mast: 64px;
    --frame: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: var(--mast) auto 1fr;
    align-content: start;
    &::before {
      border-radius: 13px;
      background: linear-gradient(0deg, #183149 0%, transparent 48%),
        linear-gradient(90deg, rgb(8 26 47 / 45%), rgb(8 26 47 / 48%)),
        #254567 url("/assets/pattaya-bay.png") center -18vw / 100% auto no-repeat;
    }
    & .brand .logo img { width: 175px; }
    & .tg { padding-inline: 12px; }
    & .hero {
      grid-area: 2 / 1 / 3 / -1;
      margin: 0;
      padding: 30px 24px 22px;
    }
    & .hero::before { width: 32px; height: 2px; margin-block-end: 12px; }
    & .hero h1 { font-size: clamp(32px, 6vw, 46px); }
    & .hero p { margin-block-start: 10px; max-width: 42ch; font-size: 15px; }
    & .brand small { display: none; }
    & .panel {
      grid-area: 3 / 1 / 4 / -1;
      align-self: start;
      justify-self: center;
      width: min(480px, calc(100% - 32px));
      margin: 0 0 16px;
    }
    & .box { padding: 24px; border-radius: 12px; }
  }
}
@media (max-width: 480px) {
  .auth:has(form:is([action="/login"], [action="/register"], [action="/2fa"])) {
    & .brand .logo img { width: clamp(116px, 39vw, 164px); }
    & .tgs { gap: 4px; }
    & .tg { height: 38px; padding-inline: 8px; font-size: 12px; }
    & .hero h1 { font-size: 32px; }
    & .hero p { display: none; }
    & .box h2 { font-size: 30px; }
    & .box { padding: 22px; }
    & .sub { margin-block-end: 18px; }
  }
}

/* Keep the six digits inside the same responsive card as the sign-in fields. */
.auth:has(.otp) .otp { max-width: none; }
.auth:has(.otp) .otp-cells { gap: clamp(4px, .7vw, 10px); }
.auth:has(.otp) .otp-cells span {
  background: var(--field);
  border-color: var(--stroke);
  color: var(--text);
  border-radius: 8px;
}
.auth:has(.otp) .otp.enhanced input { height: 100%; }
.auth:has(.otp) .otp:focus-within .active { border-color: var(--focus); outline-color: var(--focus); }
.auth:has(.otp) details.note summary { cursor: pointer; }
.auth:has(.otp) details.note form { display: grid; gap: 10px; margin-block-start: 12px; }

/* Keep the native language menu and give its indicator room in either direction. */
@media (forced-colors: none) {
  .app .main .top select.tg.language,
  .auth .tgs select.tg.language {
    appearance: none;
    padding-inline-end: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1.5 1.75 4.5 4.5 4.5-4.5' fill='none' stroke='%23758796' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: var(--language-arrow-side, right) 14px center;
  }
  [dir="rtl"] select.language { --language-arrow-side: left; }
}

/* Render the sun as the gold emoji even when the label font has a text glyph. */
[data-theme="dark"] button.tgl { font-variant-emoji: emoji; }
@supports not (font-variant-emoji: emoji) {
  [data-theme="dark"] button.tgl { display: inline-block; }
  [data-theme="dark"] button.tgl::first-letter { color: #fcc11a; }
}

@media (max-width: 480px) {
  .app:has(.frame[src="/raw/income-expenses"]) .top {
    min-height: 64px;
    height: auto;
    padding: 8px 10px;
    gap: 5px;
  }
  .app:has(.frame[src="/raw/income-expenses"]) .top h1 { font-size: 16px; line-height: 1.2; }
  .app:has(.frame[src="/raw/income-expenses"]) .top button.tg { padding-inline: 6px; white-space: nowrap; }
}
