/*
 * The editor's stylesheet.
 *
 * Written in logical properties throughout - `inset-inline`, `padding-inline`,
 * `text-align: start` - so one set of rules produces a correct screen in Hebrew
 * and in English. The alternative is a second stylesheet for RTL, which is two
 * things to keep in agreement and the second one is always the one that is
 * wrong.
 *
 * The public card has its own stylesheet, inlined into the page by
 * `src/lib/render.js`, and the two are deliberately not shared: the card is a
 * document that must load nothing, and a shared file would make its design
 * impossible to change without checking five screens that are not it.
 */

:root {
  --ink: #0d1219;
  --paper: #f5f8f8;
  --teal: #0e7c7b;
  --teal-ink: #ffffff;
  --surface: #ffffff;
  --muted: #5d6b7a;
  --line: #e3eaea;
  --bad: #b23b3b;
  --warn: #8a6100;
  --warn-bg: #fdf6e3;
  --bad-bg: #fdeeee;
  --ok-bg: #eef7f4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(13, 18, 25, .05), 0 10px 26px rgba(13, 18, 25, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef4f4;
    --paper: #0b0f14;
    --teal: #2dd4bf;
    --teal-ink: #06231f;
    --surface: #141b22;
    --muted: #93a3b2;
    --line: #222d38;
    --bad: #ff8f8f;
    --warn: #f0c674;
    --warn-bg: #2a2314;
    --bad-bg: #2b1717;
    --ok-bg: #14251f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Rubik, Arial, sans-serif;
}

h1 { font-size: 24px; margin: 0 0 14px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
a { color: var(--teal); }

/* ---------------- the chrome ---------------- */

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px clamp(12px, 4vw, 28px);
  border-block-end: 1px solid var(--line);
  background: var(--surface);
  position: sticky; inset-block-start: 0; z-index: 5;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }

.screen { padding: clamp(12px, 3vw, 24px); }

/* ---------------- controls ---------------- */

button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; background: transparent; color: inherit;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
}
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--teal); outline-offset: 2px;
}
button.primary { background: var(--teal); color: var(--teal-ink); width: 100%; justify-content: center; }
button.primary.small { width: auto; padding: 8px 14px; }
button.quiet, .button.quiet { border-color: var(--line); background: var(--surface); }
button.quiet:hover, .button.quiet:hover { border-color: var(--teal); }
button.small { padding: 7px 12px; font-size: 14px; }
button.danger, .danger { color: var(--bad); border-color: var(--line); }
button.danger:hover { border-color: var(--bad); }
button[disabled] { opacity: .45; cursor: default; }
button.iconish { padding: 6px 9px; border-color: transparent; color: var(--muted); }
button.iconish:hover:not([disabled]) { color: var(--ink); background: var(--paper); }

input, select, textarea {
  font: inherit; width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink);
}
textarea { resize: vertical; min-height: 78px; }
.hidden-file { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; }

.field { margin: 0 0 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 650; margin: 0 0 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.err { font-size: 12.5px; color: var(--bad); margin: 6px 0 0; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 14.5px; }
.check input { width: auto; }
.locked { font-size: 11.5px; font-weight: 650; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.head { justify-content: space-between; margin-block-end: 14px; }

.msg { margin: 0 0 12px; padding: 10px 13px; border-radius: 10px; font-size: 14px; background: var(--ok-bg); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.msg.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.panel.locked-panel { opacity: .92; }
.panel.plan.active, .panel.plan.grace { border-color: var(--teal); }

.address { display: block; font-size: 15px; word-break: break-all; margin: 0 0 12px; direction: ltr; unicode-bidi: isolate; }

/* ---------------- the door ---------------- */

.door { display: flex; align-items: center; justify-content: center; padding: 6vh 16px; }
.door-box {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow);
}
.door-links { display: flex; flex-direction: column; gap: 8px; margin-block-start: 16px; font-size: 14px; }
.door-links a { text-decoration: none; }

/* ---------------- the editor ---------------- */

.editor { display: grid; gap: 18px; align-items: start; }
.editor-form { min-width: 0; }
.form-head { display: flex; justify-content: flex-end; min-height: 22px; margin-block-end: 6px; }
.status { font-size: 12.5px; color: var(--muted); }
.status.saved { color: var(--teal); }

.preview-frame {
  width: 100%; height: min(78vh, 760px); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow);
}

.tabs { display: flex; gap: 6px; margin-block-end: 4px; }
.tab { border: 1px solid var(--line); background: var(--surface); flex: 1; justify-content: center; }
.tab.on { border-color: var(--teal); color: var(--teal); }

/* One markup, two layouts. Below 900px the form and the preview are tabs;
   above it they are columns and the tabs are not drawn at all. */
@media (max-width: 899px) {
  .editor.show-edit .editor-preview { display: none; }
  .editor.show-preview .editor-form { display: none; }
}
@media (min-width: 900px) {
  .tabs { display: none; }
  .editor { grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); }
  .editor .editor-preview { position: sticky; inset-block-start: 76px; }
}

/* ---------------- links ---------------- */

.links { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.link-row, .add-form { display: flex; gap: 10px; align-items: flex-start; }
.link-mark {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  background: var(--c, var(--teal)); color: #fff; display: grid; place-items: center; margin-block-start: 2px;
}
.link-body { flex: 1 1 auto; min-width: 0; }
.link-label { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin: 0 0 4px; }
.link-value { direction: ltr; unicode-bidi: isolate; }
.link-tools { display: flex; gap: 2px; margin-block-start: 20px; }

.picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  padding: 7px 12px; font-size: 14px; border-radius: 999px;
}
.chip:hover { border-color: var(--c, var(--teal)); }
.chip svg { color: var(--c, var(--teal)); }
.add-form { width: 100%; flex-wrap: wrap; }

/* ---------------- the account screen ---------------- */

.account { padding: clamp(12px, 3vw, 24px); max-width: 620px; margin-inline: auto; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
