@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&family=Patrick+Hand&family=Itim&display=swap");

/* Onpaper — hand-drawn paper-trading UI. Every colour is a token. */
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-hand); font-size: 18px; line-height: 28px; }
.pd-root { padding: var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.pd-col { display: flex; flex-direction: column; gap: var(--space-4); }

/* surfaces */
.pd-sketch { border: 2px solid var(--ink); border-radius: 255px 12px 225px 12px / 12px 225px 12px 255px; }
.pd-sheet { background: var(--paper-sheet); border: 2px solid var(--ink); border-radius: 12px 225px 12px 255px / 255px 12px 225px 12px; box-shadow: var(--shadow-sheet); padding: var(--space-4); }
.pd-ruled {
  background-color: var(--paper-sheet);
  background-image:
    linear-gradient(to right, transparent calc(var(--space-margin) - 2px), var(--margin) calc(var(--space-margin) - 2px), var(--margin) var(--space-margin), transparent var(--space-margin)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--space-rule) - 1px), var(--rule) calc(var(--space-rule) - 1px), var(--rule) var(--space-rule));
  padding-left: calc(var(--space-margin) + var(--space-3));
}
.pd-title { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 28px; margin: 0 0 var(--space-2); }
.pd-caption { font-size: 15px; line-height: 20px; color: var(--pencil); }
.pd-label { display: block; font-size: 14px; line-height: 20px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: var(--space-1); }
.pd-figure { font-size: 26px; line-height: 28px; font-variant-numeric: tabular-nums; }
.pd-gain { color: var(--gain); }
.pd-loss { color: var(--loss); }
.pd-flat { color: var(--pencil); }

/* focus: blue ballpoint ring */
.pd-btn:focus-visible, .pd-input:focus-visible, .pd-check input:focus-visible + .pd-box, .pd-tab:focus-visible, .pd-seg button:focus-visible, .pd-row:focus-visible, .pd-note-x:focus-visible {
  outline: 2px solid var(--pen-blue); outline-offset: 3px;
}

/* button */
.pd-btn {
  font: inherit; font-size: 18px; line-height: 24px; cursor: pointer;
  padding: 6px var(--space-4); color: var(--ink); background: var(--paper-sheet);
  border: 2px solid var(--ink); border-radius: 255px 12px 225px 12px / 12px 225px 12px 255px;
  box-shadow: var(--shadow-sheet); transition: transform .08s, box-shadow .08s;
}
.pd-btn:hover { background: var(--paper-shade); transform: rotate(-0.6deg); }
.pd-btn:active { box-shadow: var(--shadow-press); transform: translate(2px, 3px); }
.pd-btn[disabled], .pd-btn[disabled]:hover { color: var(--pencil); border-style: dashed; box-shadow: none; cursor: not-allowed; transform: none; background: transparent; }
.pd-btn--primary { background: var(--ink); color: var(--paper-sheet); }
.pd-btn--primary:hover { background: var(--ink-soft); }
.pd-btn--buy { background: var(--gain); color: var(--paper-sheet); border-color: var(--ink); }
.pd-btn--sell { background: var(--loss); color: var(--paper-sheet); border-color: var(--ink); }
.pd-btn--buy:hover { background: var(--gain); filter: brightness(1.12); }
.pd-btn--sell:hover { background: var(--loss); filter: brightness(1.12); }
.pd-btn--ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline wavy var(--ink-soft) 1px; text-underline-offset: 5px; }
.pd-btn--ghost:hover { background: transparent; border-color: var(--ink); }

/* input */
.pd-field { display: flex; flex-direction: column; min-width: 160px; }
.pd-input {
  font: inherit; font-size: 20px; color: var(--ink); background: transparent;
  border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; padding: 2px var(--space-1); width: 100%; box-sizing: border-box;
}
.pd-input::placeholder { color: var(--pencil); }
.pd-input[aria-invalid="true"] { border-bottom-color: var(--loss); border-bottom-style: dashed; }
.pd-hint { font-size: 15px; line-height: 20px; color: var(--pencil); margin-top: var(--space-1); }
.pd-hint--error { color: var(--loss); }
.pd-stepper { display: flex; align-items: flex-end; gap: var(--space-2); }
.pd-stepper .pd-btn { padding: 0 var(--space-3); font-size: 22px; box-shadow: none; }

/* checkbox: hand-drawn tick */
.pd-check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; user-select: none; }
.pd-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pd-box { width: 20px; height: 20px; border: 2px solid var(--ink); border-radius: 3px 6px 2px 5px; display: inline-grid; place-items: center; background: var(--paper-sheet); }
.pd-box svg { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 3; fill: none; stroke-linecap: round; stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset .25s ease-out; }
.pd-check input:checked + .pd-box svg { stroke-dashoffset: 0; }
.pd-check input:disabled + .pd-box { border-style: dashed; }
.pd-check input:disabled ~ span { color: var(--pencil); }

/* tabs: notebook dividers */
.pd-tabs { display: flex; gap: 2px; align-items: flex-end; border-bottom: 2px solid var(--ink); }
.pd-tab {
  font: inherit; font-family: var(--font-display); font-weight: 700; font-size: 22px; cursor: pointer; color: var(--ink-soft);
  padding: 2px var(--space-4) 0; background: var(--paper-shade); border: 2px solid var(--ink); border-bottom: 0;
  border-radius: 14px 18px 0 0 / 12px 16px 0 0; margin-bottom: -2px; transform: translateY(4px);
}
.pd-tab[aria-selected="true"] { background: var(--paper-sheet); color: var(--ink); transform: none; padding-bottom: 4px; }
.pd-panel { background: var(--paper-sheet); border: 2px solid var(--ink); border-top: 0; padding: var(--space-4); }
.pd-panel[hidden] { display: none; }

/* segmented buy/sell */
.pd-seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 255px 12px 225px 12px / 12px 225px 12px 255px; overflow: hidden; }
.pd-seg button { font: inherit; font-size: 18px; padding: 2px var(--space-4); border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.pd-seg button + button { border-left: 2px solid var(--ink); }
.pd-seg button[aria-pressed="true"].is-buy { background: var(--gain); color: var(--paper-sheet); }
.pd-seg button[aria-pressed="true"].is-sell { background: var(--loss); color: var(--paper-sheet); }
.pd-seg button[aria-pressed="true"]:not(.is-buy):not(.is-sell) { background: var(--ink); color: var(--paper-sheet); }

/* P&L badge: highlighter swipe */
.pd-badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0 var(--space-2); border-radius: 3px 8px 4px 9px; font-variant-numeric: tabular-nums; }
.pd-badge.pd-gain { background: var(--gain-wash); }
.pd-badge.pd-loss { background: var(--loss-wash); }
.pd-badge.pd-flat { background: var(--paper-shade); color: var(--ink-soft); }

/* quote card */
.pd-quote { width: 280px; }
.pd-quote-head { display: flex; justify-content: space-between; align-items: baseline; }
.pd-sym { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 32px; }
.pd-spark { display: block; width: 100%; height: 72px; margin: var(--space-2) 0; }
.pd-spark .ln { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pd-spark .ln2 { fill: none; stroke-width: 1; opacity: .45; }
.pd-spark .base { stroke: var(--pencil); stroke-width: 1; stroke-dasharray: 3 5; }
.pd-spark.pd-gain .ln, .pd-spark.pd-gain .ln2 { stroke: var(--gain); }
.pd-spark.pd-loss .ln, .pd-spark.pd-loss .ln2 { stroke: var(--loss); }
.pd-spark.pd-flat .ln, .pd-spark.pd-flat .ln2 { stroke: var(--ink); }
.pd-quote-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }

/* order ticket */
.pd-ticket { width: 340px; }
.pd-ticket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin: var(--space-4) 0; }
.pd-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px dashed var(--ink); padding-top: var(--space-2); margin-bottom: var(--space-4); }
.pd-ticket .pd-btn { width: 100%; }

/* positions table */
.pd-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pd-table th { text-align: left; font-weight: 400; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); background: var(--paper-shade); padding: 2px var(--space-3); border-bottom: 2px solid var(--ink); }
.pd-table td { padding: 0 var(--space-3); height: var(--space-rule); border-bottom: 1px solid var(--rule); }
.pd-table .num { text-align: right; }
.pd-table tfoot td { border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); font-size: 20px; }
.pd-row { cursor: pointer; }
.pd-row:hover td { background: var(--paper-shade); }
.pd-row[aria-selected="true"] td:first-child { box-shadow: inset 4px 0 0 var(--pen-blue); }
.pd-empty { color: var(--pencil); text-align: center; padding: var(--space-4); }

/* sticky note (toast) */
.pd-notes { display: flex; flex-direction: column; gap: var(--space-2); min-height: 60px; }
.pd-note {
  position: relative; width: 240px; padding: var(--space-2) var(--space-6) var(--space-2) var(--space-3);
  background: var(--paper-shade); border-radius: 2px 2px var(--radius-md) 2px; box-shadow: var(--shadow-note);
  transform: rotate(-1.2deg); animation: pd-stick .22s ease-out;
}
.pd-note:nth-child(even) { transform: rotate(0.9deg); }
.pd-note.pd-gain { background: var(--gain-wash); color: var(--ink); }
.pd-note.pd-loss { background: var(--loss-wash); color: var(--ink); }
.pd-note strong { font-weight: 400; }
.pd-note.pd-gain strong { color: var(--gain); }
.pd-note.pd-loss strong { color: var(--loss); }
.pd-note-x { position: absolute; top: 2px; right: 4px; border: 0; background: transparent; font: inherit; font-size: 20px; color: var(--ink-soft); cursor: pointer; line-height: 20px; }
@keyframes pd-stick { from { opacity: 0; transform: translateY(-8px) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .pd-note, .pd-btn, .pd-box svg { animation: none; transition: none; } }
