/* ============================================================
   fax — minimal, framework-free CSS
   ============================================================ */

:root {
  --bg: #f5f1e6;
  --paper: #ffffff;
  --ink: #2a221a;
  --muted: #7a6f5e;
  --accent: #5a7a45;
  --accent-ink: #ffffff;
  --danger: #b14a44;
  --warn: #d39a2a;
  --info: #3f6fa4;
  --line: #d6cdb8;
  --code-bg: #2a221a;
  --code-fg: #f5f1e6;
  --shadow: 0 1px 0 rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

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

code, pre, var {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-style: normal;
}

pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.45;
}

pre code { background: none; padding: 0; color: inherit; }

code:not(pre code) {
  background: rgba(0, 0, 0, .06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}

var {
  color: var(--accent);
  background: rgba(90, 122, 69, .12);
  padding: 1px 4px;
  border-radius: 4px;
}

button {
  font: inherit;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .04s ease, background .15s ease;
}
button:hover { background: #3f352a; }
button:active { transform: translateY(1px); }
button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
button.danger:hover { background: var(--danger); color: var(--paper); }
button.link {
  background: none;
  border: none;
  color: var(--info);
  padding: 0;
  text-decoration: underline;
}

input[type="text"] {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 122, 69, .18);
}

h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 44px; letter-spacing: -.5px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin-top: 18px; color: var(--muted); }

main {
  max-width: 760px;
  margin: 0 auto 80px;
  padding: 0 20px;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 20px 50px;
}

/* ============================================================
   Home page
   ============================================================ */

.hero {
  text-align: center;
  padding: 40px 20px 24px;
}
.hero-art {
  width: 280px;
  height: 192px;
  margin: 0 auto 8px;
}
.faxgeraet { width: 100%; height: 100%; pointer-events: none; }
.hero .tagline { color: var(--muted); margin-top: 0; }
.hero .tagline em { color: var(--accent); font-style: normal; font-weight: 600; }
.hero .sub {
  max-width: 540px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.create .input-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.create input[type="text"] { flex: 1; }
.create label { font-weight: 600; font-size: 14px; }
.create .hint, .recent .hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

.recent-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.recent-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.recent-list li:last-child { border-bottom: none; }
.recent-list a {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.recent-list .when { color: var(--muted); font-size: 12px; }
.recent-list .remove {
  background: none;
  border: none;
  color: var(--muted);
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 4px;
}
.recent-list .remove:hover { background: rgba(0, 0, 0, .06); color: var(--danger); }
.recent-actions { margin-top: 12px; }

.readme h3 { margin-top: 20px; }
.readme ul.caveats { padding-left: 20px; color: var(--muted); font-size: 14px; }
.readme ul.caveats li { margin: 4px 0; }

/* ============================================================
   View page
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
}
.brand-icon { width: 36px; height: 24px; }

.fax-id {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.fax-id code {
  background: rgba(0, 0, 0, .06);
  padding: 4px 8px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.fax-id button {
  background: transparent;
  color: var(--info);
  border-color: var(--info);
  padding: 5px 10px;
  font-size: 13px;
}
.fax-id button:hover { background: var(--info); color: var(--paper); }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(90, 122, 69, .6);
}
.status-dot[data-state="live"] { background: var(--accent); animation: pulse 1.8s ease-out infinite; }
.status-dot[data-state="connecting"] { background: var(--warn); }
.status-dot[data-state="error"] { background: var(--danger); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(90, 122, 69, .55); }
  70%  { box-shadow: 0 0 0 8px rgba(90, 122, 69, 0); }
  100% { box-shadow: 0 0 0 0   rgba(90, 122, 69, 0); }
}
.badge {
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.controls { display: flex; align-items: center; gap: 12px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { margin: 0; }

.empty {
  padding: 40px 0 20px;
  color: var(--muted);
}
.empty-head {
  text-align: center;
  padding: 0 20px 12px;
}
.faxgeraet-empty { width: 220px; height: 160px; opacity: .8; }
.empty-head h2 { color: var(--ink); margin-top: 4px; }
.empty-head p { max-width: 540px; margin: 8px auto 0; font-size: 14px; }
.empty-foot { text-align: center; margin-top: 30px; font-size: 13px; }

/* Quickstart examples grid */
.examples {
  margin: 24px 0 0;
  display: grid;
  gap: 14px;
}
.example {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow);
}
.example h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
}
.example > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.example pre {
  position: relative;
  margin: 0;
  padding-right: 76px; /* leave room for the copy button */
}

/* Copy button (injected by view.js) */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(245, 241, 230, .14);
  color: var(--code-fg);
  border: 1px solid rgba(245, 241, 230, .25);
  opacity: 0;
  transition: opacity .12s ease, background .12s ease;
  letter-spacing: .02em;
}
.example pre:hover .copy-btn,
.example pre:focus-within .copy-btn,
.copy-btn:focus,
.copy-btn.copied {
  opacity: 1;
}
.copy-btn:hover { background: rgba(245, 241, 230, .22); }
.copy-btn.copied {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.requests { list-style: none; padding: 0; margin: 20px 0 0; }
.req {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: slide-in .25s ease-out;
}
@keyframes slide-in {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.req-head {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: none;
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-align: left;
  border-radius: 0;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.req-head:hover { background: #faf6ea; }
.req[data-collapsed="true"] .req-head { border-bottom: none; }
.method {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  text-align: center;
  color: var(--paper);
  background: var(--muted);
}
.method.GET    { background: var(--info); }
.method.POST   { background: var(--accent); }
.method.PUT    { background: var(--warn); }
.method.PATCH  { background: #8a5fb5; }
.method.DELETE { background: var(--danger); }
.method.HEAD, .method.OPTIONS { background: var(--muted); }

.path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.size, .time { font-size: 12px; color: var(--muted); }
.size.warn { color: var(--danger); font-weight: 600; }

.req-body { background: #faf6ea; padding: 12px 14px 14px; }

/* Inline body preview ------------------------------------------------- */

.body-preview {
  position: relative;
  max-height: 320px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--code-bg);
}
.body-preview.expanded {
  max-height: none;
}
.body-preview > pre {
  margin: 0;
  border-radius: var(--radius);
  max-height: none; /* container handles clipping */
  overflow-x: auto;
}
.body-preview > p.binary-note {
  margin: 0;
  padding: 8px 14px;
  background: rgba(255, 255, 255, .08);
  color: var(--code-fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
/* Empty-body note sits on the paper, not on a dark code bg. */
.body-preview[data-kind="empty"] {
  background: transparent;
  border: 1px dashed var(--line);
}
.body-preview[data-kind="empty"] > p.binary-note {
  background: transparent;
  color: var(--muted);
}

/* Fade-out gradient appears when body is clipped (not expanded). */
.body-preview:not(.expanded)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(42, 34, 26, 0) 0%,
    rgba(42, 34, 26, .85) 100%
  );
  opacity: 0;
  transition: opacity .15s ease;
}
.body-preview.is-clipped:not(.expanded)::after { opacity: 1; }
.body-preview[data-kind="empty"]::after { display: none; }

/* Image preview. */
.body-preview[data-kind="image"] {
  background: repeating-conic-gradient(
    #ece6d3 0% 25%, #f5f1e6 0% 50%
  ) 0 0 / 16px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.body-preview[data-kind="image"] img {
  max-width: 100%;
  max-height: 304px; /* leave room for padding inside the 320 cap */
  display: block;
}
.body-preview[data-kind="image"].expanded img {
  max-height: none;
}
.body-preview[data-kind="image"]::after {
  background: linear-gradient(
    to bottom,
    rgba(245, 241, 230, 0) 0%,
    rgba(245, 241, 230, .92) 100%
  );
}

/* Action row (expand, download, open full size). */
.body-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 2px 0;
  font-size: 13px;
}
.body-actions .link { padding: 0; }
.body-actions a.link { color: var(--info); }

/* Headers + cURL as collapsible details ----------------------------- */

details.extra {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
details.extra > summary {
  cursor: pointer;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
  user-select: none;
}
details.extra > summary::-webkit-details-marker { display: none; }
details.extra > summary::before {
  content: "▸ ";
  display: inline-block;
  width: 1em;
  transition: transform .12s ease;
}
details.extra[open] > summary::before {
  content: "▾ ";
}
details.extra > summary:hover { color: var(--ink); }

.headers-table { padding: 4px 12px 10px; }
.headers-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.headers-table td {
  vertical-align: top;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}
.headers-table td.k { color: var(--muted); white-space: nowrap; width: 30%; }
.headers-table tr:last-child td { border-bottom: none; }
.headers-table .secret-reveal {
  background: rgba(0, 0, 0, .06);
  border: none;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  color: var(--ink);
}
.curl-snippet {
  margin: 4px 12px 12px;
  max-height: 200px;
  overflow: auto;
}

.meta {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
}
.meta .warn { color: var(--danger); font-weight: 600; }
