/*
Theme Name: Un Araignée au Plafond (fr)
Theme URI: https://unearaigneeauplafond.fr/
Description: Un thème responsive, deux colonnes, avec un mode sombre/clair et impression A4.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: unearaigneeauplafond
*/

:root {
  color-scheme: light;
  --bg-color: #f4f4f9;
  --text-color: #333333;
  --link-color: #0066cc;
  --header-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --border-color: #e0e0e0;
  --pre-bg: #eeeeee;
  --pre-text: #333333;
  --hero-bg: #e6f2ff;
  --btn-bg: #0066cc;
  --btn-text: #ffffff;
  --btn-hover: #004c99;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --link-color: #66b2ff;
    --header-bg: #1e1e1e;
    --sidebar-bg: #1e1e1e;
    --border-color: #333333;
    --pre-bg: #2d2d2d;
    --pre-text: #cccccc;
    --hero-bg: #2a3b4c;
    --btn-bg: #3388ff;
    --btn-text: #ffffff;
    --btn-hover: #66b2ff;
  }
}

* {
  box-sizing: border-box;
}

figure {
  margin: 0;
}

html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

a:hover,
a:focus {
  text-decoration: underline;
  color: var(--btn-hover);
}

img,
audio,
video,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* User requirement: "Les images incluses dans les pages et posts doivent prendre la largeur du contenu principal automatiquement, sauf les vignettes qui prennent la taille qui leur est associée." */
.entry-content img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5em 0;
}

.entry-content img.wp-post-image,
.entry-content img.thumbnail,
.entry-content img.alignnone,
.entry-content img.alignleft,
.entry-content img.alignright,
.entry-content img.aligncenter,
.entry-content img.size-thumbnail {
  width: auto;
  max-width: 100%;
  margin: auto;
}

figcaption,
.wp-block-image figcaption,
.wp-block-gallery figcaption {
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  margin-top: 0.5em;
  margin-bottom: 1.5em;
  opacity: 0.8;
  position: relative !important;
  background: none !important;
  color: inherit !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  padding: 0 !important;
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

.site-header {
  background-color: var(--header-bg);
  padding: 0.05rem 0;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.site-header .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

@media (min-width: 768px) {
  .site-header .container {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

.site-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.site-title a {
  color: var(--text-color);
}

.site-description {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  opacity: 0.8;
}

.main-navigation {
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .main-navigation {
    margin-top: 0;
  }
}

.main-navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.5rem;
}

.main-navigation a {
  color: var(--text-color);
  font-weight: 500;
}

.main-navigation a:hover {
  color: var(--link-color);
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-content {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 2.5rem 1rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.site-main {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  /* fixes flexbox truncation issue */
}

/* User requirement: "Lorsque la largeur ne le permet pas, supprime la barre latérale." */
.site-sidebar {
  width: 320px;
  background-color: var(--sidebar-bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

@media (max-width: 900px) {
  .site-sidebar {
    display: none !important;
  }

  .site-content {
    flex-direction: column;
  }
}

.full-width {
  width: 100%;
}

.hentry {
  background-color: var(--header-bg);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

@media (max-width: 768px) {
  .hentry {
    padding: 1.5rem 1rem;
  }
}

.entry-title {
  margin-top: 0;
  font-size: 2.5rem;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.entry-title a {
  color: var(--text-color);
}

.entry-meta {
  font-size: 0.9rem;
  opacity: 0.7;
  margin-bottom: 1.5rem;
}

.entry-content {
  font-size: 1.1rem;
  line-height: 1.8;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.wp-block-video,
.wp-block-audio {
  margin: 1.5em 0;
}

/* Author box */
.author-box {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  padding: 1.5rem;
  background-color: var(--hero-bg);
  border-radius: 8px;
  margin-top: 3rem;
  gap: 1.5rem;
}

.author-avatar img {
  border-radius: 50%;
  width: 80px;
  height: 80px;
  margin: 0;
}

.author-info {
  flex: 1;
  min-width: 200px;
}

.author-name {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}

.author-bio {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  opacity: 0.9;
}

.author-signature {
  margin: 0;
  font-style: italic;
  font-weight: 600;
}

/* Comments */
.comments-area {
  margin-top: 3rem;
  padding: 2rem;
  background-color: var(--header-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.comment-list {
  list-style: none;
  padding: 0;
}

.comment-body {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.comment-author .avatar {
  border-radius: 50%;
  width: 60px;
  height: 60px;
}

.comment-meta {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.comment-content {
  flex: 1;
}

.reply a {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: var(--hero-bg);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Pre tag block */
.code-container {
  position: relative;
  margin: 1.5rem 0;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background-color: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s, background-color 0.2s;
  z-index: 10;
}

.copy-btn:hover {
  opacity: 1;
  background-color: var(--btn-hover);
}

pre {
  background-color: var(--pre-bg);
  color: var(--pre-text);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  max-width: 100%;
  font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.5;
}

.hljs-ln {
  width: 100%;
  table-layout: fixed !important;
}

.hljs-ln td {
  border: none;
  padding: 0;
}

.hljs-ln-numbers {
  text-align: right;
  color: #888888;
  border-right: 1px solid #888888 !important;
  vertical-align: top;
  padding-right: 10px !important;
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  white-space: nowrap;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.hljs-ln-code {
  padding-left: 15px !important;
  text-align: left;
  width: 100% !important;
  word-break: break-all;
  white-space: pre-wrap;
}

/* Site Footer */
.site-footer {
  background-color: var(--header-bg);
  padding: 2rem 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
}

/* Print styles (A4, light theme only) */
@media print {
  :root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --link-color: #000000;
    --header-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --border-color: #cccccc;
    --pre-bg: #f5f5f5;
    --pre-text: #000000;
    --hero-bg: #ffffff;
  }

  @page {
    size: A4;
    margin: 2cm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
  }

  .site-header,
  .site-footer,
  .site-sidebar,
  .copy-btn,
  .reply {
    display: none !important;
  }

  .site-content {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .site-main,
  .hentry,
  .full-width {
    width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  a {
    text-decoration: none !important;
    color: #000000 !important;
  }

  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  pre {
    page-break-inside: avoid;
    border: 1px solid #ccc;
  }
}