/* Copyright (c) 2022, The Tor Project, Inc. */

/* General rules */

html,
body {
  width: 100%;
  height: 100%;
}

label {
  display: flex;
  align-items: center;
  padding: var(--space-small) 0;
}

input[type="text"] {
  margin: 0;
  width: 360px;
  max-width: 100%;
}

textarea {
  margin: 0;
  width: var(--content-width);
  max-width: 100%;
  box-sizing: border-box;
}

select,
option {
  font-weight: var(--font-weight-bold);
}

dt {
  margin: var(--ruleset-vmargin) 0 0 0;
  padding: 0;
  color: var(--text-color-deemphasized);
  font-size: var(--font-size-small);
}

dd {
  margin: var(--space-small) 0 0 0;
  padding: 0;
  max-width: 600px;
  box-sizing: border-box;
}

hr {
  width: 40px;
  margin: 0;
  border: none;
  border-block-start: var(--border-width) solid var(--border-color);
}

.hidden {
  display: none !important;
}

/* Initial warning */

#warning-wrapper {
  display: none;
}

.state-warning #warning-wrapper {
  display: flex;
  align-items: center;
  height: 100%;
}

#warning {
  margin-top: -20vh;
  padding: 0 160px;
  background-image: url("chrome://global/skin/icons/warning.svg");
  background-position: 84px 0;
  background-repeat: no-repeat;
  background-size: 48px;
  fill: #ffbd4f;
  -moz-context-properties: fill;
}

#warning:dir(rtl) {
  background-position: right 84px top 0;
}

#warning-description {
  margin: var(--space-xxlarge) 0 var(--space-large) 0;
}

#warning-buttonbar {
  margin-top: var(--space-xxlarge);
  text-align: right;
}

/* Actual content */

:root {
  --sidebar-width: 320px;
  --content-width: 600px;
  --ruleset-vmargin: 40px;
}

#main-content {
  display: flex;
  height: 100%;
}

.state-warning #main-content {
  display: none;
}

section {
  display: none;
  flex: 1 0 auto;
  padding: var(--space-xxlarge);
}

.title {
  display: flex;
  align-items: center;
  width: var(--content-width);
  max-width: 100%;
  padding-bottom: var(--space-large);
  border-bottom: var(--border-width) solid var(--border-color);
}

.title h1 {
  margin: 0;
  padding: 0;
  padding-inline-start: var(--space-xxlarge);
  font-size: var(--font-size-xlarge);
  font-weight: var(--font-weight-bold);
  background-image: url("chrome://browser/content/rulesets/securedrop.svg");
  background-position: 0 center;
  background-size: var(--icon-size-large);
  min-height: var(--icon-size-large);
  background-repeat: no-repeat;
}

#main-content h1:dir(rtl) {
  background-position: right 0 center;
}

/* Ruleset list */

aside {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-width);
  box-sizing: border-box;

  border-inline-end: var(--border-width) solid var(--border-color);
  background-color: var(--background-color-box);
}

#ruleset-heading {
  padding: var(--space-large);
  text-align: center;
  font-weight: var(--font-weight-bold);
  border-bottom: var(--border-width) solid var(--border-color);
}

#ruleset-list-container {
  flex: 1;
}

#ruleset-list-empty {
  padding: var(--space-large);
  text-align: center;
}

#ruleset-list-empty-description {
  font-size: var(--font-size-small);
}

#ruleset-list {
  margin: 0;
  padding: 0;
}

#ruleset-list li {
  display: flex;
  align-items: center;
  margin: 0;
  padding: var(--space-medium) var(--space-large);
  list-style: none;
  border-inline-start: 4px solid transparent;
  border-block-end: var(--border-width) solid var(--border-color);
}

#ruleset-list li:last-child {
  border-bottom: none;
}

#ruleset-list .icon {
  width: var(--icon-size);
  height: var(--icon-size);
  margin-inline-end: var(--space-medium);
  background-image: url("chrome://browser/content/rulesets/securedrop.svg");
  background-size: var(--icon-size);
}

#ruleset-list .icon.has-favicon {
  background: transparent;
}

#ruleset-list .name {
  font-weight: var(--font-weight-bold);
}

#ruleset-list .description {
  font-size: var(--font-size-small);
  color: var(--text-color-deemphasized);
}

#ruleset-list .selected {
  border-inline-start-color: var(--color-accent-primary);
}

#ruleset-list .selected.disabled {
  border-inline-start-color: var(--border-color);
}

#ruleset-list li:not(.selected):hover {
  background-color: var(--button-background-color-hover);
  color: var(--button-text-color-hover);
}

#ruleset-list li:not(.selected):hover:active {
  background-color: var(--button-background-color-active);
}

#ruleset-list #ruleset-template {
  display: none;
}

/* Ruleset details */

.state-details #ruleset-details {
  display: block;
}

#ruleset-jwk-value {
  padding: var(--space-small);
  border-radius: var(--border-radius-xsmall);
  background-color: var(--background-color-box);
  font-size: var(--font-size-small);
  line-break: anywhere;
  /* ASCII-only text, so can set line-height. */
  line-height: 1.4;
}

#ruleset-edit {
  margin-inline-start: auto;
  padding-inline-start: var(--space-xxlarge);
  background-image: url("chrome://global/skin/icons/edit.svg");
  background-repeat: no-repeat;
  background-position: var(--space-small);
  -moz-context-properties: fill;
  fill: currentColor;
  min-width: auto;
  flex: 0 0 auto;
}

#ruleset-enable {
  margin-top: var(--ruleset-vmargin);
}

#ruleset-buttonbar {
  margin: var(--ruleset-vmargin) 0;
}

#ruleset-updated {
  margin-top: var(--space-xlarge);
  color: var(--text-color-deemphasized);
  font-size: var(--font-size-small);
}

/* Edit ruleset */

.state-edit #edit-ruleset {
  display: block;
}

#edit-ruleset label {
  color: var(--text-color-deemphasized);
  display: block;
}

#edit-ruleset label,
#edit-buttonbar {
  margin-top: var(--ruleset-vmargin);
}

label#edit-enable {
  display: flex;
  align-items: center;
}
