/* Shared base styling */

/* Include padding and border in element width and height by default */

html
{
  box-sizing: border-box;
}
*, *::before, *::after
{
  box-sizing: inherit;
}

/* Set base colors */

body
{
  color: var(--text);
  background: var(--inverse);
}

/* Reset and override user agent styling with sensible defaults */

body,
html,
header,
footer,
main,
section,
h1, h2, h3,
p,
ul,
ol,
li,
table,
img,
form,
legend,
input,
textarea,
button,
turbo-frame
{
  margin: 0;
  padding: 0;
  font-size: 100%;
  font-weight: inherit;
  border: none;
}
h1, h2, h3,
p,
ul,
ol,
table
{
  margin: 1rem 0;
}
h1:has(+h2)
{
  margin-bottom: 0;
}
h1 + h2
{
  margin-top: 0;
}
h1
{
  font-size: 150%;
}
h2,
dialog h1
{
  font-size: 125%;
}
h3
{
  font-weight: bold;
}
li
{
  list-style-type: none;
}
button,
input[type=email],
input[type=search],
input[type=tel],
input[type=text],
input[type=url],
textarea,
turbo-frame,
img,
svg
{
  display: block;
}
button,
input[type=email],
input[type=search],
input[type=submit],
input[type=tel],
input[type=text],
input[type=url],
textarea
{
  color: inherit;
  background: none;
  -webkit-appearance: none;
}
button
{
  border: none;
  -webkit-tap-highlight-color: transparent;
}
button,
label,
input[type=submit]
{
  cursor: pointer
}
abbr
{
   text-decoration: inherit;
   font-variant: inherit;
}
a,
input[type=submit]  /* use `input[type=submit]` for “link-style” form submission */
{
  color: var(--control-primary);
}
a[href]:active,
input[type=submit]:active
{
  color: var(--control-primary-active);
}

/* Turbo progress bar */

.turbo-progress-bar
{
  height: 2px;
  background: var(--link);
}

/* Make the page body fill the viewport height and keep the footer at the bottom */

body
{
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body > header,
body > footer
{
  flex: 0 0 auto;
}
body > main
{
  flex: 1 0 auto;
}

/* Page header and footer */

body > header,
body > footer
{
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0 var(--inset-right) 0 var(--inset-left);
}
body > header
{
  background: var(--control-primary);
}
body > footer
{
  border-top: 1px solid var(--border);
}
body > header,
body > header a
{
  color: var(--inverse);
}
body > header p,
body > footer p
{
  margin: 0;
}
body > header p
{
  padding: var(--inset-top) 0 0.5rem 0;
}
body > footer p
{
  padding: 0.5rem 0 var(--inset-bottom) 0;
}

/* Main wraps the main content on the page */

main
{
  padding: 1rem var(--inset-right) 1rem var(--inset-left);
  background: var(--main);
}
body:not(:has(> header)) main
{
  padding-top: max(var(--inset-top), 1rem);
}
body:not(:has(> footer)) main
{
  padding-bottom: max(var(--inset-bottom), 1rem);
}
main > *:first-child,
main > *:first-child > *:first-child
{
  margin-top: 0 !important;
}
main > *:last-child,
main > *:last-child > *:last-child
{
  margin-bottom: 0 !important;;
}

/* Sections are used to separate two or more groups of non-field elements */

section + section
{
  margin-top: 2rem;
}

/* Emails preview */

div.preview
{
  max-width: 48rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--inverse);
}
div.preview > *:first-child
{
  margin-top: 0
}
div.preview > *:last-child
{
  margin-bottom: 0
}
div.preview pre
{
  width: min-content;
  margin: 1.5rem 2rem;
  padding: 0.5rem 1rem;
  border: 0.5rem solid var(--border);
  border-radius: 0.25rem;
  font-size: 2rem;
}

/* Allow Stimulus controllers to show and hide elements using a classname */

.hidden
{
  display: none;
}

/* Hide non-essential elements when the viewport gets narrow */

@media (max-width: 48rem) {
  .narrow_hidden
  {
    display: none;
  }
}

/* Preserve newlines in text with paragraphs (that’s otherwise unformatted) */

.preserve-newlines
{
  white-space: pre-line;
}

/* Animation to indicate that a relatively small element has appeared or updated */

.bump
{
  animation: 0.3s ease-out bump;
}
@keyframes bump {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  10% {
    transform: scale(1.25);
  }
  50% {
    opacity: 1;
  }
  90% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}
