/* KAORU */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-color: #ffffff;
  --text-color: #2a2a2a;
  --text-light: #6a6a6a;
  --border-color: #d0d0d0;
  --link-color: #4a4a4a;
  --code-bg: #f5f5f5;
  --max-width: 800px;
}

body {
  font-family: monospace, 'Courier New', Courier;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  padding: 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: bold;
  margin: 1em 0 0.5em 0;
  line-height: 1.2;
  color: var(--text-color);
}

h1 { font-size: 1.8em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.2em; }

p {
  margin: 0.5em 0;
  text-align: justify;
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--text-light);
  text-underline-offset: 3px;
  transition: text-decoration-style 0.3s ease, text-decoration-color 0.3s ease;
}

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

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

/* Header */
header {
  margin-bottom: 2em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border-color);
}

header a {
  color: var(--text-color);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.header-left {
  flex: 1 1 auto;
  min-width: 0;
}

.header-right {
  display: flex;
  gap: 1em;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5em;
  }
  
  .header-right {
    gap: 0.5em;
  }
}

/* Border boxes */
.border {
  border: 1px solid var(--border-color);
  padding: 1em;
  margin: 1em 0;
}

/* Lists */
ul, ol {
  margin: 0.5em 0 0.5em 2em;
}

ul.toc, ol.toc {
  list-style-position: inside;
}

ul.list {
  list-style-type: none;
  margin-left: 0;
}

/* Table of Contents */
#toc ul, #toc ol {
  margin-left: 1.5em;
}

/* Code */
code {
  background-color: var(--code-bg);
  padding: 0.1em 0.3em;
  font-family: monospace;
  font-size: 0.95em;
  color: var(--text-color);
}

pre {
  background-color: var(--code-bg);
  padding: 1em;
  overflow-x: auto;
  margin: 1em 0;
  border: 1px solid var(--border-color);
}

pre code {
  background: none;
  padding: 0;
}

/* Layout helpers */
.frontpage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2em;
}

.left, .right {
  min-width: 0;
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

th, td {
  border: 1px solid var(--border-color);
  padding: 0.5em;
  text-align: left;
}

/* Footer */
footer {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-light);
}

subfooter {
  display: block;
  text-align: center;
  margin: 1em 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

/* License */
license {
  display: block;
  text-align: center;
  margin-top: 2em;
  font-size: 0.9em;
  color: var(--text-light);
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 10px;
    font-size: 13px;
  }

  .frontpage {
    grid-template-columns: 1fr;
  }

  h1 { font-size: 1.5em; }
  h2 { font-size: 1.3em; }
  h3 { font-size: 1.1em; }
}

/* Aside elements */
.right-aside, .left-aside {
  border: 1px solid var(--border-color);
  padding: 1em;
  margin: 1em;
  max-width: 40%;
  text-align: justify;
}

.right-aside {
  float: right;
  margin-left: 1em;
}

.left-aside {
  float: left;
  margin-right: 1em;
}

.center {
  max-width: 80%;
  margin: 1em auto;
  text-align: center;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* On hover shadow */
img:hover {
  box-shadow: 1px 1px 19px rgba(0, 0, 0, 0.2);
  transform: scale(1.02);
}

img.left {
  float: left;
  margin: 0 1em 1em 0;
  max-width: 40%;
}

img.right {
  float: right;
  margin: 0 0 1em 1em;
  max-width: 40%;
}

img.border {
  border: 1px solid var(--border-color);
}

img.shadow {
  box-shadow: 5px 5px 10px rgba(0,0,0,0.15);
}

img.glow {
  box-shadow: 0 0 10px rgba(128,128,128,0.3);
}

img.flip {
  transform: scaleX(-1);
}

/* Sidenotes - inspired by Tufte CSS, adapted for Hugo shortcodes
   Usage: place {{< sidenote >}}...{{< /sidenote >}} on its own line before the paragraph.
*/

.sidenote, aside.sidenote {
  /* mobile first: visible, boxed */
  display: block;
  border: 1px solid var(--border-color);
  border-left-width: 3px;
  border-left-color: var(--text-light);
  background-color: rgba(0,0,0,0.03);
  padding: 0.5em;
  margin: 0.75em 0;
  font-size: 0.95em;
  color: var(--text-light);
}

/* Desktop: float aside to the left of the following paragraph */
@media (min-width: 768px) {
  .sidenote, aside.sidenote {
    position: relative;
    float: left;
    width: 220px;
    margin: 0;
    margin-left: calc(-220px - 1rem);
    margin-right: 1rem;
    padding: 0;
    text-align: right;
    border: none;
    background-color: transparent;
  }
  /* When multiple sidenotes appear consecutively, clear the second so they stack nicely. */
  .sidenote + .sidenote, aside.sidenote + aside.sidenote {
    clear: left;
    margin-top: 0.5rem;
  }
}

/* Gallery grid - 4 columns of square thumbnails */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1em 0;
}

.gallery-item {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: none;
}

.gallery-item img:hover {
  transform: none;
  box-shadow: none;
}

/* Responsive: 2 columns on mobile */
@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

/* Center standalone images inside article content (does not affect floated images) */
.content p > img:not(.left):not(.right),
.content a > img:not(.left):not(.right),
.content img:not(.left):not(.right) {
  display: block;
  margin: 1.25rem auto;
  max-width: 100%;
  max-height: 75vh;
  height: auto;
  object-fit: contain;
}

/* Markdown figure support */
.content figure {
  margin: 1.25rem auto;
  text-align: center;
}
.content figure img {
  display: block;
  margin: 0 auto;
}

/* Fancy centered blockquotes */
.content blockquote {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-style: italic;
  text-align: center;
  width: min(60ch, 90%);
  margin: 2rem auto;
  padding: 0.25em 0;
  color: var(--text-light);
}
.content blockquote p {
  margin: 0.5em 0;
  text-align: center !important;
}
.content blockquote cite,
.content blockquote footer {
  display: block;
  margin-top: 0.5em;
  font-style: normal;
  font-size: 0.95em;
  opacity: 0.8;
}

/* Startpage styles */
.startpage {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.startpage-header {
  text-align: right;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.startpage-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: normal;
}

.startpage-header a {
  display: inline-block;
  margin-bottom: 0.5rem;
  text-decoration: none;
}

.startpage-content {
  margin-bottom: 2rem;
}

.startpage-quote {
  margin: 2rem 0;
  padding: 1rem 2rem;
  border-left: 3px solid var(--border-color);
  font-style: italic;
  color: var(--text-color);
}

.startpage-quote p {
  text-align: left;
}

.startpage-section {
  margin: 2rem 0;
  padding: 1rem 0;
  border-left: 1px solid var(--border-color);
}

.startpage-section h2 {
  margin: 0 0 1rem 0;
  padding-left: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 1.5rem;
  font-weight: 300;
}

.startpage-section ul {
  display: inline-block;
  margin: 0 2rem 1rem 0;
  padding-left: 1rem;
  vertical-align: top;
  list-style: none;
}

.startpage-section li {
  margin: 0.3rem 0;
}

.startpage-section a {
  text-decoration: none;
  color: var(--link-color);
}

.startpage-section a:hover {
  text-decoration: underline;
}

.startpage-footer {
  text-align: right;
  font-size: 0.9rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-light);
}

/* Responsive startpage */
@media (max-width: 768px) {
  .startpage {
    padding: 1rem;
  }
  
  .startpage-section ul {
    display: block;
    margin: 0 0 1rem 0;
  }
  
  .startpage-header h1 {
    font-size: 1.5rem;
  }
  
  .startpage-section h2 {
    font-size: 1.2rem;
  }
}