:root {
  /* Light mode colors */
  --bg-color: white;
  --bg-color-muted: #eee;
  --text-color: black;
  --text-color-muted: #999;
  --blockquote-color: green;
  --sticky-color: #dcfeda;
  --gilded: darkorange;
  --link-color: #29BC9B;
  --link-visited-color: #999;
  --accent: var(--link-color);
  --error-text-color: red;
  --border-radius-card: 0.5vmin;
  --border-radius-media: 0.5vmin;
  --border-radius-preview: 0.3vmin;

  font-family: Inter, sans-serif;
  font-feature-settings: 'ss01' 1, 'kern' 1, 'liga' 1, 'cv05' 1, 'dlig' 1, 'ss01' 1, 'ss07' 1, 'ss08' 1;

}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #161e27;
    --bg-color-muted: #333;
    --text-color: #f1f3f5;
    --text-color-muted: #93a5b7;
    --blockquote-color: lightgreen;
    --sticky-color: #014413;
    --gilded: gold;
    --link-color: #79ffe1;
    --link-visited-color: #999;
    --accent: var(--link-color);
    --error-text-color: lightcoral;
  }
}

@supports (font-variation-settings: normal) {
  :root { font-family: InterVariable, sans-serif; }
}

html {
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  background-color: var(--bg-color);
  color: var(--text-color);
}

body.media-maximized {
  /* Fix for Safari User Agent stylesheet */
  margin: 0;
}

body.media-maximized.zoom,
div.media-maximized.container.zoom {
  overflow: auto;
}

img.media-maximized {
  cursor: zoom-in;
}

img.media-maximized.zoom {
  max-width: unset;
  max-height: unset;
  cursor: zoom-out;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header a,
.sub-title a,
.info-container a,
.comment-info-container a,
.sort-opts a,
.view-opts a,
.more a
{
  text-decoration: none;
}

a {
  color: var(--link-color);
}

a:hover {
  color: var(--link-color);
  text-decoration: underline;
}

a:visited {
  color: var(--link-visited-color);
}

.header {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.sub-title {
  display: flex;
}

#button-container {
  margin-left: 10px;
  display: flex;
  align-items: center;
}

.sorting,
.viewing {
  margin-top: 20px;
}

.sort-opts,
.view-opts {
  display: grid;
  margin: 10px;
}

.sort-opts,
.view-opts {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(5, 1fr);
  grid-auto-flow: column;
}

.view-opts {
  grid-template-rows: repeat(2, 1fr);
}

.footer {
  display: flex;
  flex-direction: row;
}

.footer-item {
  margin-left: auto;
}

nav {
  display: flex;
  align-items: stretch;
}

.post {
  margin-bottom: 5px;
}

.post, .comments-container, .hero, .header, .footer {
  padding: 0.3rem;
  flex: 1 1 95%;
  width: 100%;
}

.post, .hero {
  font-size: 0.9rem;
}

.post-container.card {
  border: 1px solid var(--bg-color-muted);
  border-radius: var(--border-radius-card);
  display: block;
}

.post-text.card {
  padding: 0.9rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  overflow-wrap: break-word;
  max-width: 95%;
}

.self-text-overflow.card {
  /* For spoiler positioning */
  position: relative;
  padding-top: 0.3rem;
  max-height: 10vh;
  overflow: hidden;
  overflow-wrap: break-word;
  display: block;
  max-width: 98%;
}

.self-text.card {
  overflow: hidden;
  display: -webkit-box;
  /* Safari on iOS <= 17 */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  text-overflow: ellipsis;
}

.image-viewer {
  position: relative;
}

.image-viewer > img {
  cursor: pointer;
}

.spoiler {
  background-color: rbga(var(--bg-color-muted), 0.2);
  /* Safari on iOS <= 17 */
  -webkit-backdrop-filter: blur(3rem);
  backdrop-filter: blur(3rem);
  border-radius: var(--border-radius-preview);

  position: absolute;
  top: 0;
  left: 0;
  
  box-sizing: border-box;
  display: flex;
  height: 100%;
  width: 100%;
  
  justify-content: center;
  align-items: center;

  cursor: pointer;

  z-index: 10;
}

.gallery-item-idx,
.spoiler > h2 {
  text-shadow: 0.1rem 0.1rem 1rem var(--bg-color-muted);
}

.comments-container {
  font-size: 0.9rem;
}

.info-container a,
.info-container,
.comment-info-container,
.more,
summary::before
{
  color: var(--text-color-muted)
}

.info-container, .more {
  font-size: 0.8rem;
  display: flex;
}

summary::before {
  font-size: 0.7rem;
}

.comment-info-container {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
}

.domain {
  color: var(--text-color-muted);
  font-size: 0.8rem;
}

.info-item, .header-item, .footer-item {
  margin-right: 14px;
}

.media-preview img,
.media-preview video {
  object-fit: cover;
  width: 4rem;
  height: 4rem;
  border-radius: var(--border-radius-preview);
}

.image-viewer img,
.image-viewer video {
  border-radius: var(--border-radius-media);

  max-height: 50vh;
  max-width: 95%;

  display: block;
  width: unset;
  height: unset;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0.5rem;

  object-fit: fill;
}

.image-viewer.main-content img,
.image-viewer.main-content video {
  max-height: 70vh;
}

.image-viewer a:has(img) {
  font-size: 0rem;
  padding: unset;
  margin: unset;
}

.media-maximized {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  display: block;
  margin: auto;
  object-fit: contain;
}

.media-maximized.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.post-author {
  display: none
}

.post-media {
  display: block;
  margin: 0 auto;
  width: 95%;
  padding: 5px;
}
 
form {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
}

@media (min-width: 768px) {
  :root {
    --border-radius-card: 0.5vmin;
    --border-radius-media: 0.5vmin;
    --border-radius-preview: 0.3vmin;  
  }
  .post, .comments-container, .hero, .header, .footer {
    flex: 1 1 90%;
    width: 90%;
  }
  .media-preview img,
  .media-preview video 
  {
    width: 5rem;
    height: 5rem;
  }
  .image-viewer img,
  .image-viewer video
  {
    max-height: 50vh;
  }
  .post-text.card {
    max-width: 100%;
  }
  .self-text-overflow.card {
    max-width: 100%;
  }
  .post-author {
    display: inline
  }
  .post-media {
    width: 50%;
  }
  form {
    width: 40%;
  }
  .sort-opts,
  .view-opts {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(1, 1fr);
    grid-auto-flow: row;
  }
}

@media (min-width: 1080px) {
  :root {
    --border-radius-card: 0.5vmin;
    --border-radius-media: 0.5vmin;
    --border-radius-preview: 0.3vmin;
  }
  .post, .comments-container, .hero, .header, .footer {
    flex: 1 1 60%;
    width: 60%;
  }
  .media-preview img,
  .media-preview video 
  {
    width: 5rem;
    height: 5rem;
  }
  .image-viewer img,
  .image-viewer video
  {
    max-height: 45vh;
  }
  .media-preview a {
    font-size: 2rem;
    padding: 2rem;
  }
  .self-text.card {
    -webkit-line-clamp: 4;
    line-clamp: 4;
  }
  .post-author {
    display: inline
  }
  .post-media {
    width: 50%;
  }
  form {
    width: 20%;
  }
  .sort-opts,
  .view-opts {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(1, 1fr);
    grid-auto-flow: row;
  }
}

@media (min-width: 2560px) {
  .post, .comments-container, .hero, .header, .footer {
    flex: 1 1 40%;
    width: 40%;
  }
  .image-viewer img,
  .image-viewer video
  {
    max-height: 30vh;
  }
  .sort-opts,
  .view-opts {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(1, 1fr);
    grid-auto-flow: row;
  }
}

.comment, .more {
  width: 100%;
  border-left: 1px dashed var(--text-color-muted);
  padding: 8px 0px 0px 18px;
  box-sizing: border-box;
}

.comment {
  padding-top: 10px;
}

.first {
  border-left: none;
  padding-left: 0;
  margin-top: 10px;
}

.post-info {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.post-container:target {
  outline: 4px solid var(--bg-color-muted);
  background: var(--bg-color-muted);
  border-radius: 2px;
  padding: 5px;
}

.post-text {
  display: flex;
  flex-direction: column;      
  align-items: stretch;        
  justify-content: space-evenly;
}

.media-preview {
  padding-left: 10px;
  margin-left: auto;
}

.bottom-links-container {
  display: flex;
  flex-direction: row;
}

.title-container, .comment-info-container, summary.expand-comments::before {
  margin-top: 5px;
  margin-bottom: 5px;
}

.info-container {
  flex: 1;
}

.title-container > a {
  color: var(--text-color);
  text-decoration: none;
}

.title-container.card > a {
  font-size: 1.125rem;
  font-weight: bold;
}

.title-container > a:hover {
  text-decoration: underline;
}

.title-container > a:visited {
  color: var(--text-color-muted)
}

.header a,
.sort-opts a,
.view-opts a,
.sub-title a {
  color: var(--text-color);
}

.more a {
  color: var(--text-color-muted);
}

hr {
  border: none;
  border-top: 1px dashed var(--text-color-muted);
  height: 0;
}

blockquote {
  margin: 0px;
  padding-left: 10px;
  border-left: 2px solid var(--blockquote-color);
  color: var(--blockquote-color);
}

pre, code {
  background: var(--bg-color-muted);
}

pre {
  padding: 10px 0px 10px 10px;
  width: 100%;
  overflow: auto;
}

code {
  overflow-x: auto;
}

p {
  margin-top: 5px;
  margin-bottom: 0px;
}

.self-text p {
  margin-top: 10px;
  margin-bottom: 10px;
}

.comment-body {
  text-align: left;
  display: block;
  padding-bottom: 8px;
}

.comment-body img {
  height: auto;
  max-width: 300px;
}

summary.expand-post {
  display: none;
}

summary {
  list-style: none;
  cursor: pointer;
}

summary::-webkit-details-marker {
  display: none;
}

details[open] summary::before {
  content: "";
  padding-right: 10px;
}

details:not([open]) summary::before {
  content: "";
  padding-right: 10px;
}

.footer {
  padding-bottom: 40px;
}

a {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.gallery {
  display: flex;
  overflow-x: auto;
  position: relative;
  padding: 5px;
  align-items: center;
  scroll-snap-type: both mandatory;
}

.gallery-item {
  flex: 0 0 auto;
  margin-right: 10px;
  max-width: 100%;
  width: 100%;
  scroll-snap-align: center;
}

.gallery-item-idx {
  text-align: center;
}

.post-title {
  margin-top: 5px;
}

.op {
  color: var(--accent);
}

.gilded {
  color: var(--gilded);
}

button {
  border: 0px solid;
  border-radius: 2px;
  background-color: var(--bg-color-muted);
  color: var(--text-color);
  padding: 5px;
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  box-sizing: border-box;
  border: 1px solid var(--bg-color-muted);
  border-radius: 4px;
  background-color: var(--bg-color-muted);
  color: var(--text-color);
}

form label {
  width: 100%;
  flex-basis: 100%;
  margin: 5px 0;
  color: var(--text-color);
}

form input[type="submit"] {
  width: 100%;
  padding: 10px 20px;
  margin-top: 20px;
  background-color: var(--link-color);
  color: var(--bg-color);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

form input[type="submit"]:hover {
  background-color: var(--link-color);
  opacity: 0.8;
}

.input-text {
  width: 100%;
}

.submit-button {
  margin: 24px 0;
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.submit-button button {
  width: 100%;
  padding: 12px;
  background-color: var(--accent);
  color: var(--bg-color);
}

.submit-button button:disabled {
  width: 100%;
  padding: 12px;
  background-color: var(--bg-color-muted);
  color: var(--text-color-muted);
}

.register-error-message,
.dashboard-error-message {
  margin-bottom: 1rem;
  flex-flow: row wrap;
  color: var(--error-text-color);
}

.register-message {
  margin-bottom: 1rem;
  flex-flow: row wrap;
}

.invite-table {
  width: 100%;
  padding: 10px 0;
}

.invite-table th,
.invite-table td
{
  padding: 5px 0;
}

.invite-table-header {
  text-align: left;
}

.invite-link {
  font-family: monospace;
}

.search-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  width: 100%;
  gap: 10px;
}

.search-input {
  flex: 9;
}

.search-button {
  flex: 1;
  padding: 10px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.about {
  padding-bottom: 20px;
}

a.nav-link {
  color: var(--text-color-muted);
}

.comment-info-container > p {
  margin-top: 0px;
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  text-indent: 1px;
  text-overflow: '';
}

.sticky {
  background-color: var(--sticky-color);
  border-radius: var(--border-radius-card);
  border: 4px solid var(--sticky-color);
}

.inline {
  max-width: 100%;
}
