/* SealFlipper — CSS Grade B target, Grade D for lock overlay only */

html {
  font-size: 100%;
}

body {
  font-family: sans-serif;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ── Typography ─────────────────────────────────────────────────────────── */

h1 { font-size: 2rem; margin-top: 1rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
small { font-size: 0.8rem; }

/* ── Header & nav ───────────────────────────────────────────────────────── */

header {
  border-bottom: 1px solid;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

header strong {
  font-size: 1.2rem;
}

nav ul {
  list-style: none;
  margin: 0.5rem 0 0 0;
  padding: 0;
}

nav ul li {
  display: inline-block;
  margin-right: 1rem;
}

nav ul li a {
  text-decoration: none;
}

nav ul li a.active {
  font-weight: bold;
  text-decoration: underline;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid;
  margin-top: 2rem;
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

input[type="text"],
input[type="password"],
textarea {
  font-family: sans-serif;
  font-size: 1rem;
  width: 100%;
  max-width: 32rem;
  padding: 0.3rem;
  border: 1px solid;
  box-sizing: border-box;
}

textarea {
  font-family: monospace;
  resize: vertical;
}

button {
  font-size: 1rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
  margin-right: 0.5rem;
}

button.btn-danger {
  background-color: #c00;
  color: #fff;
  border: 1px solid #900;
}

label {
  font-weight: bold;
}

fieldset {
  border: 1px solid;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
}

legend {
  font-weight: bold;
}

/* Checkbox labels inside fieldset are not bold */
fieldset label {
  font-weight: normal;
}

/* ── Feedback messages ──────────────────────────────────────────────────── */

.error {
  color: #c00;
  font-weight: bold;
}

.success {
  color: #060;
  font-weight: bold;
}

/* ── Public key display ─────────────────────────────────────────────────── */

.pubkey-display {
  display: block;
  font-family: monospace;
  font-size: 0.8rem;
  word-break: break-all;
  white-space: pre-wrap;
  max-width: 32rem;
  border: 1px solid;
  padding: 0.3rem;
}

/* ── Inline avatar ──────────────────────────────────────────────────────── */

#identity-avatar canvas,
#contacts-list p canvas,
#recipient-list canvas,
#open-sender canvas {
  vertical-align: middle;
}

/* ── Sender status ──────────────────────────────────────────────────────── */

.sender-valid      { color: green; }
.sender-invalid    { color: red; }
.sender-unverified { color: orange; }

/* ── QR code container ──────────────────────────────────────────────────── */

#identity-qr {
  margin: 1rem 0;
}

#identity-qr img,
#identity-qr canvas {
  display: block;
  max-width: 200px;
  height: auto;
  background: #ffffff;
  padding: 8px;
}

/* ── QR scanner ─────────────────────────────────────────────────────────── */

#qr-scanner-container {
  max-width: 320px;
  border: 1px solid;
}

#qr-video {
  display: block;
  width: 100%;
  height: auto;
}

#qr-canvas {
  display: none;
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Add-contact sub-panel ──────────────────────────────────────────────── */

#add-contact-panel {
  display: none;
  border: 1px solid;
  padding: 1rem;
  margin-top: 1rem;
}

#add-contact-panel.open {
  display: block;
}

/* Sub-tabs inside add-contact panel use same nav style */
#add-contact-tabs ul {
  list-style: none;
  margin: 0 0 1rem 0;
  padding: 0;
}

#add-contact-tabs ul li {
  display: inline-block;
  margin-right: 1rem;
}

#ac-panel-paste,
#ac-panel-scan {
  display: none;
}

#ac-panel-paste.active,
#ac-panel-scan.active {
  display: block;
}

/* ── Contacts list ──────────────────────────────────────────────────────── */

#contacts-list p {
  border-bottom: 1px solid;
  padding-bottom: 0.5rem;
}

/* ── Recipient list inside flip form ────────────────────────────────────── */

#recipient-list label {
  display: block;
  font-weight: normal;
  margin-bottom: 0.3rem;
}

/* ── Flip result areas (hidden until result is available) ───────────────── */

#seal-result,
#open-result {
  display: none;
  margin-top: 1rem;
  border-top: 1px solid;
  padding-top: 1rem;
}

#seal-result.visible,
#open-result.visible {
  display: block;
}

/* ── Flip panel toggle ──────────────────────────────────────────────────── */

#flip-panel-seal,
#flip-panel-open {
  display: none;
}

#flip-panel-open.active,
#flip-panel-seal.active {
  display: block;
}

/* ── Screen visibility ──────────────────────────────────────────────────── */

#screen-setup,
#screen-app {
  display: none;
}

#screen-setup.active,
#screen-app.active {
  display: block;
}

/* ── Lock screen — Grade D: position:fixed justified ───────────────────── */

#screen-lock {
  display: none;
}

#screen-lock.active {
  display: block;
}

#lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  z-index: 100;
  padding: 2rem;
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  #lock-overlay {
    background-color: #111;
  }
}

@media (max-width: 32rem) {
  body {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  input[type="text"],
  input[type="password"],
  textarea {
    max-width: 100%;
  }

  .pubkey-display {
    max-width: 100%;
  }
}
