/* The note trigger's visibility and the web panel it opens. The platform's
   file, not the app's: keep it as it is. The trigger's own look is the app's,
   in styles.css; this file only hides it from anyone who may not leave a note,
   and draws the panel — Second Draft's own, in its plum and pink and its house
   shape (the corner opened top-right), the same as the change box in the
   workspace, so a note plainly goes to Second Draft and not to the app. */

/* The phone's corner. A shell that knows the page declares its own trigger
   draws no button in the bottom-right corner, so the space every app keeps
   for it closes up: --shell-slot is 0. Only inside an older shell, which still
   draws its button whatever the page says, does second-draft-note.js mark the
   corner kept and the space come back. A browser never had a button there. */
:root:has(meta[name="second-draft-note-trigger"][content="app"]) { --shell-slot: 0px; }
html[data-second-draft-corner="kept"] {
  --shell-slot: calc(var(--shell-switcher-inset, 16px) + var(--shell-switcher-size, 48px) + var(--shell-switcher-gap, 16px)) !important;
}

/* Hidden until second-draft-note.js has asked who is here and been told yes. */
html:not([data-second-draft-notes="on"]) [data-second-draft-note] { display: none !important; }
[data-second-draft-note] { cursor: pointer; }
[data-second-draft-note] .sd-mark { display: block; flex: none; }
[data-second-draft-note] .sd-mark-box { position: relative; display: inline-flex; flex: none; }

/* Something waits for the person in the workspace: a small dot over the
   trigger's top-right corner, inside its box, so the trigger keeps its size
   and the mark stays whole. :where() leaves the app's own position standing,
   should it have one. The colour is the app's to set, if red clashes. */
:where([data-second-draft-note][data-second-draft-waiting]) { position: relative; }
[data-second-draft-note] .sd-waiting {
  position: absolute; top: 5px; right: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--second-draft-waiting, #d7401d);
  box-shadow: 0 0 0 2px var(--second-draft-waiting-ring, #fff);
  pointer-events: none;
}
/* On the mark itself when the module drew it: its top-right corner, just outside. */
[data-second-draft-note] .sd-mark-box > .sd-waiting { top: -3px; right: -6px; }

.sd-note {
  --sd-ink: #2c2029;
  --sd-quiet: #5f4f59;
  --sd-card: #ffffff;
  --sd-line: #ece4e9;
  --sd-line-strong: #cdbcc5;
  --sd-field: #ffffff;
  --sd-wash: #fbeef2;
  --sd-plum: #4a2138;
  --sd-act: #4a2138;
  --sd-on-act: #fff5f7;
  --sd-focus: #965673;
  /* The house shape, its opened corner about 40% of what it is on. */
  --sd-house-card: 4px 26px 4px 4px;
  --sd-house-control: 3px 18px 3px 3px;
  --sd-house-field: 3px 16px 3px 3px;
  color-scheme: light;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--sd-house-card);
  background: var(--sd-card);
  color: var(--sd-ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 0 0 1px var(--sd-line), 0 18px 48px rgba(42, 30, 37, 0.3);
  overflow: auto;
  text-align: left;
}
@media (prefers-color-scheme: dark) {
  .sd-note {
    --sd-ink: #f2e9ee;
    --sd-quiet: #c9b8c2;
    --sd-card: #2f232b;
    --sd-line: #45363f;
    --sd-line-strong: #5a4652;
    --sd-field: #241a21;
    --sd-wash: #3d2c36;
    --sd-plum: #edb9cf;
    --sd-act: #f7d6de;
    --sd-on-act: #4a2138;
    --sd-focus: #edb9cf;
    color-scheme: dark;
  }
}
/* On a phone the panel sits at the top: centred, the keyboard came up over the
   words box and the buttons, since an app's page does not shrink for it. */
@media (max-width: 600px) {
  .sd-note { width: calc(100vw - 16px); max-width: none; margin: calc(12px + env(safe-area-inset-top, 0px)) auto auto; max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px)); }
  .sd-note > .sd-note-card { padding-inline: 16px; }
}
.sd-note::backdrop { background: rgba(42, 30, 37, 0.45); }
.sd-note *, .sd-note *::before, .sd-note *::after { box-sizing: border-box; }
.sd-note-card { padding: 16px 18px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.sd-note-head { display: flex; align-items: center; gap: 10px; color: var(--sd-plum); }
.sd-note-head h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--sd-ink); }
.sd-note-close {
  appearance: none; border: 0; background: transparent; color: var(--sd-ink);
  min-width: 44px; min-height: 44px; margin: -8px -10px -8px 0; border-radius: var(--sd-house-control);
  font: 400 28px/1 system-ui, sans-serif; cursor: pointer;
}
.sd-note-form { display: grid; gap: 10px; margin: 0; }
/* Like the buttons below: one line each and the same height, two rows sooner than a taller button. */
.sd-note-kinds { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.sd-note-kind {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px; border: 1.5px solid var(--sd-line-strong); border-radius: var(--sd-house-control);
  white-space: nowrap; color: var(--sd-quiet); font-size: 0.9rem; font-weight: 600; cursor: pointer; text-align: center;
}
.sd-note-kind input { position: absolute; opacity: 0; pointer-events: none; }
.sd-note-kind:has(input:checked) { border-color: var(--sd-plum); background: var(--sd-wash); color: var(--sd-plum); font-weight: 700; }
.sd-note-kind:has(input:focus-visible) { outline: 2px solid var(--sd-focus); outline-offset: 2px; }
.sd-note-label { font-weight: 700; font-size: 0.95rem; }
.sd-note textarea {
  width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px;
  border: 1.5px solid var(--sd-line-strong); border-radius: var(--sd-house-field); background: var(--sd-field); color: var(--sd-ink);
  font: inherit;
}
.sd-note textarea:focus { border-color: var(--sd-plum); outline: none; }
.sd-note-about { margin: 0; color: var(--sd-quiet); font-size: 0.85rem; overflow-wrap: anywhere; }
.sd-note-status { margin: 0; font-size: 0.95rem; }
.sd-note-status:empty { display: none; }
.sd-note-status a { color: inherit; font-weight: 700; }
.sd-note-send {
  appearance: none; border: 0; border-radius: var(--sd-house-control); min-height: 46px; padding: 10px 18px;
  background: var(--sd-act); color: var(--sd-on-act); font: 700 1rem/1 system-ui, sans-serif; cursor: pointer;
  justify-self: end;
}
.sd-note-send:disabled, .sd-note-other:disabled { opacity: 0.6; cursor: progress; }
.sd-note-send[hidden], .sd-note-choices[hidden], .sd-note-waiting[hidden] { display: none; }

/* A change: one thing to reach for, and two quieter ones beside it, in one row. */
.sd-note-choices { display: grid; gap: 8px; }
/* Each as wide as its words, the room left shared out; on the narrowest screens the row wraps rather than spill. */
.sd-note-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-note-row > .sd-note-send, .sd-note-row > .sd-note-other { flex: 1 1 auto; min-height: 46px; padding-inline: 8px; white-space: nowrap; font-size: 0.9rem; }
.sd-note-other {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--sd-plum); border-radius: var(--sd-house-control);
  background: transparent; color: var(--sd-plum); text-decoration: none; text-align: center;
  font: 600 0.95rem/1.2 system-ui, sans-serif; cursor: pointer;
}
.sd-note-other:hover { background: var(--sd-wash); }
.sd-note-hint { margin: 0; color: var(--sd-quiet); font-size: 0.85rem; }

/* What waits for the person in the workspace, at the top of the panel. */
.sd-note-waiting {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 10px 12px; border-radius: var(--sd-house-field); background: var(--sd-wash); font-size: 0.95rem;
}
.sd-note-waiting a { color: inherit; font-weight: 700; text-underline-offset: 3px; }
.sd-note-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--second-draft-waiting, #d7401d); }
.sd-note-more { display: flex; gap: 8px; border-top: 1px solid var(--sd-line); padding-top: 8px; }
.sd-note-link {
  appearance: none; border: 0; background: transparent; color: var(--sd-plum);
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: var(--sd-house-control);
  font: 600 0.95rem/1 system-ui, sans-serif; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.sd-note-link:first-child { margin-left: -10px; }
.sd-note button:focus-visible, .sd-note a:focus-visible { outline: 2px solid var(--sd-focus); outline-offset: 2px; }
.sd-note-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
